Re: SQL help
| From: | Marc Greenstock | Date: | Wed, 11 Feb 2004 03:06:43 +0000 |
| Subject: | Re: SQL help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177342@lists.php.net to get a copy of this message | ||
The DB is MySQL 4.0.16,
all tables are MyISAM
"Martin Towell" <martin.towell@world.net> wrote in message
news:690FCB376F13B8419BF7C47034EEC7A416F962@exchange.world.net...
> You'll need to do a left/right outer join.
>
> as you didn't say which database you're using, I'll give this back to you
to
> do some reading up on how to do it...
>
> HTH
> Martin
>
>
> > -----Original Message-----
> > From: Marc Greenstock [mailto:marc@shockmedia.com.au]
> > Sent: Wednesday, 11 February 2004 1:53 PM
> > To: php-general@lists.php.net
> > Subject: [PHP] SQL help
> >
> >
> > Hi all here's my problem,
> >
> > I have two tables: 'user_data' and 'image_data'
> >
> > obviously user_data has all the user information and
> > image_data has all the
> > image information
> >
> > in image_data are the fields: Image_ID int(11), User_ID int(11) and
> > Default_Img enum('Yes','No'). Users can have as many images
> > as they like,
> > but it is optional.
> >
> > I want to select from user_data and image_data and get the
> > results based
> > upon the rest of the query. The problem is my sql is only
> > pulling out the
> > users with images and ignoring the rest
> >
> > my sql looks like this:
> >
> > SELECT * FROM user_data, image_data
> > WHERE user_data.User_ID = image_data.User_ID
> > AND image_data.Default_Img = 'Yes'
> > GROUP BY user_data.User_ID
> >
> > thanks for your help.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >