Re: Two tables (Slightly 0T)
| From: | Petar Nedyalkov | Date: | Sat, 16 Apr 2005 13:57:49 +0000 |
| Subject: | Re: Two tables (Slightly 0T) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-213197@lists.php.net to get a copy of this message | ||
On Saturday 16 April 2005 17:06, Ryan A wrote:
> Hey,
> My host has MySql 4.0.x so I cant really use the nested selects of 4.1 :-(
> please tell me how you solved something like this;
>
> I have two tables:
> users_online (username , dateandtime)
> users_details (cno, username, has_image, image_name)
>
> 1a) I have to select x records from users_online where $username is not
> more than 3 minutes old,
> 1b) then I have to check if that username has_image,if yes, get the
> imagename
>
> I thought of having the imagename also in the users_details, but we are
> allowing our members to
> change/modify their images at will....
>
> What kind of sql do I use above? I dont want to run a query on every record
> returned from users_online
> as that would be really "expensive".
See the JOIN syntax in MySQL. You can join the two tables.
http://dev.mysql.com/doc/mysql/en/join.html
BTW this is a question for the [MySQL General] list at mysql@lists.mysql.com.
:-)
>
> Thanks,
> Ryan
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.9.13 - Release Date: 4/16/2005
--
Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)
PGP ID: 7AE45436
PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc
PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436
Attachment: [application/pgp-signature]
Attachment: [application/pgp-signature]