By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,327 Members | 1,891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,327 IT Pros & Developers. It's quick & easy.

Join 3 tables display first record only

P: 1
Could someone help me please I have three tables:

gallery
gallery_images
users

I am joining data from the three tables the problem is that there are multiple records that appear in the gallery_images that relate to one gallery record.
I need to display the first record only while joining the three tables.

This is the sql query so far:

SELECT * FROM gallery, gallery_images, users
WHERE gallery.guser = users.uid
AND users.uid = " & uid & "
AND gallery.gid = gallery_images.gid"

This will return the results for the three tables but how can I change to display the first record of the gallery_images table only.

Any help would be great thanks
Nov 30 '06 #1
Share this Question
Share on Google+
1 Reply


NeoPa
Expert Mod 15k+
P: 31,661
Could someone help me please I have three tables:

gallery
gallery_images
users

I am joining data from the three tables the problem is that there are multiple records that appear in the gallery_images that relate to one gallery record.
I need to display the first record only while joining the three tables.

This is the sql query so far:

SELECT * FROM gallery, gallery_images, users
WHERE gallery.guser = users.uid
AND users.uid = " & uid & "
AND gallery.gid = gallery_images.gid"

This will return the results for the three tables but how can I change to display the first record of the gallery_images table only.

Any help would be great thanks
Try this and then try to explain clearly what you get and what you would prefer to get.
Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT * " & _
  2.     "FROM (users INNER JOIN gallery " & _
  3.         "ON users.uid=gallery.guser) " & _
  4.         "INNER JOIN gallery_images " & _
  5.         "ON gallery.gid = gallery_images.gid" & _
  6.     "WHERE gallery.guser = " & uid
Nov 30 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.