#1222 - The used SELECT statements have a different number of columns

后端 未结 5 715
Happy的楠姐
Happy的楠姐 2021-02-13 19:55

Why am i getting a #1222 - The used SELECT statements have a different number of columns ? i am trying to load wall posts from this users friends and his self.

S         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-13 20:36

    (
            SELECT b.id AS id, b.pid AS pid, b.message AS message, b.date AS date FROM 
            wall_posts AS b 
            JOIN Friends AS f ON f.id = b.pid 
            WHERE f.buddy_id = '1' AND f.status = 'b'
            ORDER BY date DESC
            LIMIT 0, 10
        )
        UNION
        (
            SELECT id, pid  , message , date  
            FROM
            wall_posts
            WHERE pid = '1'
            ORDER BY date DESC
            LIMIT 0, 10
        )
    

    You were selecting 4 in the first query and 6 in the second, so match them up.

提交回复
热议问题