Re: question, about mysql query

From: Date: Tue, 03 Jun 2008 17:14:57 +0000
Subject: Re: question, about mysql query
Groups: php.general 
Request: Send a blank email to php-general+get-274962@lists.php.net to get a copy of this message
---- LKSunny <ad@pc86.com> wrote: > two table, tablea and tableb > tablea > uid, col1, col2, col3 > 1, xx, xx, xx > 2, xx, xx, xx > 3, xx, xx, xx > tableb > id, uid, col1, firstdata > 1, 1, xx, 1 > 2, 2, xx, 0 > 3, 2, xx, 0 > 4, 1, xx, 0 > > i want query tablea, and join tableb, uid is associate, ok "LEFT JOIN > tableb b ON a.uid = b.uid", and than i want tableb > firstdata=1 or tableb > no associate uid "b.firstdata=1 OR b.uid IS NULL", by the time all ok, but i > want add one case, if tableb firstdata all is 0, result one row, like b.uid > IS NULL, i don't know how to > > i want result is all tablea data no double, tableb one case firstdata is 1 > (one uid in tableb just one row possible is firstdata=1), or no row in > tableb, or all firstdata = 0 > > Thank You Very Much !! > > This query can't > SELECT a.*, b.* FROM tablea a LEFT JOIN > tableb b ON a.uid = b.uid WHERE > (b.firstdata=1 OR b.firstdata=0 OR b.uid IS NULL) You could pass the logic through the PHP and just do a cursory check there and drop the rows from printing out which are NULL But in all honesty, your words jumbled together and you have posted NO PHP CODE for us to look at, so it's a best guess. You might want to try posting your MySQL problems to a MySQL list if you are having MySQL problems. If you are having PHP code problems, then by all means post your non-working but definitely being used code here and we'll be glad to help you figure out what is not working. Wolf

« previous php.general (#274962) next »