Miko Posted February 24, 2010 Share Posted February 24, 2010 Hi, I'm trying to create a query that will get data from t1 and if not found go search in t2. I have this for the moment: SELECT * FROM tbl1, tbl2 WHERE tbl1.clnr = '$clnr' OR tbl2.clnr = '$clnr' This kinda works but Instead of receiving 1 result I get the same result 100 times. Anyone an idea? thanks Quote Link to comment https://forums.phpfreaks.com/topic/193232-very-simple-query/ Share on other sites More sharing options...
fenway Posted February 24, 2010 Share Posted February 24, 2010 You can't do that -- that' a cartesian product. You need to JOIN the two tables, and then, depending on what's in that column, use COALESCE(). Quote Link to comment https://forums.phpfreaks.com/topic/193232-very-simple-query/#findComment-1017658 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.