RE: [PHP] URGENT - Help in mySql query

From: Date: Thu, 18 Oct 2001 02:48:16 +0000
Subject: RE: [PHP] URGENT - Help in mySql query
Groups: php.general 
Request: Send a blank email to php-general+get-71437@lists.php.net to get a copy of this message
Ah, you didn't say that :) I see where you're going now. I thought it was a 1:1 relationship with large text fields moved out for db speed. J -- Jason Murray jasonm@melbourneit.com.au Web Developer, Melbourne IT "Work now, freak later!" > -----Original Message----- > From: Manisha [mailto:manisha@aurica.com] > Sent: Thursday, October 18, 2001 12:46 PM > To: Jason Murray; php-general@lists.php.net > Subject: RE: [PHP] URGENT - Help in mySql query > > > But this won't serve my purpose as for me the count of first table is > important. > > For example, > > newsletter newsletterArticle > 1 2 articles > > 2 3 articles > > 3 1 articles > > 4 no articles > > Then the query > > SELECT * > FROM newsletter, newsletterArticle > WHERE newsletter.ID = newsletterArticle.refID; > > will return me record count as 6 where as I want it as 3 > (i.e. master > table count). That's why this query won't give me the > required results. > > Any other solution ? (like distinct / exists ? ) > > manisha > > At 12:34 PM 10/18/01 +1000, Jason Murray wrote: > >Pretty simple really: > > > >SELECT * > > FROM newsletter, newsletterArticle > > WHERE newsletter.ID = newsletterArticle.refID; > > > >... will only pull out data when the condition is satisfied. > > > >Jason > > > >-- > >Jason Murray > >jasonm@melbourneit.com.au > >Web Developer, Melbourne IT > >"Work now, freak later!" > > > > > -----Original Message----- > > > From: Manisha [mailto:manisha@aurica.com] > > > Sent: Thursday, October 18, 2001 12:29 PM > > > To: php-general@lists.php.net > > > Subject: [PHP] URGENT - Help in mySql query > > > > > > > > > hi, > > > > > > I want to write one query. I have 2 tables one as a master > > > and another as > > > detail. > > > > > > 1) newsletter - master table - ID and title is stored > > > 2) newsletterArticle - details table - artID, refID (ref of > > > master table) > > > and body text is stored. > > > > > > I want to display the newsletter only if I found > > > corresponding record in > > > newsletterArticle. > > > > > > i.e if in newsletter there is an entry for ID 1, but no article in > > > newsletterArticle, then I do not want to display that record. > > > > > > This I want to achieve in single query. Something like below > > > > > > select ID from newsletter where (select count(*) from > > > newsletterArticle > > > where refID = the ID of newsletter ???? > 0) > > > > > > Platform - PHP / mySql /BSDi > > > > > > > > > Any help ? It is very urgent > > > > > > manisha > > > > > > > > > > > > > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > For additional commands, e-mail: php-general-help@lists.php.net > > > To contact the list administrators, e-mail: > > > php-list-admin@lists.php.net > > > > > > >-- > >PHP General Mailing List (http://www.php.net/) > >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > >For additional commands, e-mail: php-general-help@lists.php.net > >To contact the list administrators, e-mail: > php-list-admin@lists.php.net >

« previous php.general (#71437) next »