GinsBabu Posted October 27, 2009 Share Posted October 27, 2009 Hi, i do have a join query for 2 tables.i want to display a field as null if it is NULL.how can i do that?Also i have a where condition.what if i want to select value from first table even if the where condition is not satisfied. Quote Link to comment https://forums.phpfreaks.com/topic/179154-join-problem/ Share on other sites More sharing options...
GinsBabu Posted October 27, 2009 Author Share Posted October 27, 2009 Hi, i do have a join query for 2 tables.i want to display a field as null if it is NULL.how can i do that?Also i have a where condition.what if i want to select value from first table even if the where condition is not satisfied.Mysql version is 5.1 Quote Link to comment https://forums.phpfreaks.com/topic/179154-join-problem/#findComment-945191 Share on other sites More sharing options...
gevensen Posted October 27, 2009 Share Posted October 27, 2009 download toad its free and has a query builder that makes those complex statements Quote Link to comment https://forums.phpfreaks.com/topic/179154-join-problem/#findComment-945218 Share on other sites More sharing options...
kickstart Posted October 27, 2009 Share Posted October 27, 2009 Hi For the first part, try something like this:- SELECT *, if(b.id IS NULL, 'null',b.id) FROM table1 a LEFT OUTER JOIN table2 b ON a.id = b.PageId Not sure what you want with a WHERE clause that is ignored. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/179154-join-problem/#findComment-945247 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.