Results 1 to 3 of 3
May 16, 2004, 03:02 #1
- Join Date
- Mar 2004
- united states
- 0 Post(s)
- 0 Thread(s)
how to combine two queries into one?
I have two tables:
Image_ID INT UNSIGNED NOT NULL
ID INT UNSIGNED NOT NULL,
Width INT UNSIGNED NOT NULL,
Height INT UNSIGNED NOT NULL,
Thumbnail_ID INT UNSIGNED NOT NULL
The Image table stores information about all the images in the database.
If a certain image has a thumbnail, the ID of the thumbnail is stored in the Thumbnail_ID column (otherwise 0 is stored)
The Image_ID column in the settings table defines the ID for an image (which has a thumbnail) which is used a logo in the system.
I would like to extract the following in a single query:
The width & height of the thumbnail image for the image whose ID is stored in the settings table.
I can do this in two queries:
$id = select Thumbnail_ID from image where settings.Image_ID = Image.ID;
select Width, Height from Image where ID = $id;
is it possible to do it in a single query?
maybe the design of the tables is wrong?
what would be a better design?