techker Posted April 18, 2010 Share Posted April 18, 2010 hey guys i have 2 databases that are exacly the same.but one is cars the other is cars2 i need to echo all of the contents of both togetter. inventory page. so i tryed looking up left join im struggeling with this .. SELECT * cars LEFT JOIN cars2 works but thable 1 cars only show the id's not the rest of the info and table 2 cars 2 show it all? both have the same fields(copy paste) Quote Link to comment https://forums.phpfreaks.com/topic/198929-left-join-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 18, 2010 Share Posted April 18, 2010 JOIN's are used when you have data that has some defined relationship in more than one table (i.e. the R in RDBMS.) To do what you are attempting, you would use a UNION, however, you generally won't ever have same-meaning data split up into multiple tables as that creates several data management and performance problems. Quote Link to comment https://forums.phpfreaks.com/topic/198929-left-join-error/#findComment-1044179 Share on other sites More sharing options...
techker Posted April 18, 2010 Author Share Posted April 18, 2010 so i used $query = "(SELECT * FROM cars ) UNION (SELECT * FROM cars2 ) ORDER BY ID LIMIT 10; "; The used SELECT statements have a different number of columns Quote Link to comment https://forums.phpfreaks.com/topic/198929-left-join-error/#findComment-1044183 Share on other sites More sharing options...
F1Fan Posted April 18, 2010 Share Posted April 18, 2010 hey guys i have 2 databases that are exacly the same.but one is cars the other is cars2 i need to echo all of the contents of both togetter. How can they have a different number of columns? Quote Link to comment https://forums.phpfreaks.com/topic/198929-left-join-error/#findComment-1044186 Share on other sites More sharing options...
PFMaBiSmAd Posted April 18, 2010 Share Posted April 18, 2010 I've got the same question. both have the same fields(copy paste) The used SELECT statements have a different number of columns Both those statements cannot be true at the same time. You would need to show what your tables are, what your data is, and what the expected results are for anyone one to be able to help you at this point. Quote Link to comment https://forums.phpfreaks.com/topic/198929-left-join-error/#findComment-1044187 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.