MySQL: joins, The used SELECT statements have a different number of columns -


i know there more questions can`t find right answer me.

this query:

$query = $mysql->query("(                         select questions.*, tags.tagdata                         questions                         left join tags                         on questions.id = tags.questid                         )                         union (                         select users.username                         users                         left join questions                         on users.id = questions.ownerid                         )                     "); 

i select questions in table questions, tags save ownerid id of owner , want username display. error:

the used select statements have different number of columns

what doing wrong?

why need union ? question table linked user , can use in join

select questions.*,  tags.tagdata, users.username questions left join tags on  tags.questid = questions.id  left join users on users.id = questions.ownerid 

Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -