Jump to content

SQL Query problem


mmcb

Recommended Posts

Yep, I've got another problem for you all.
I have 2 MySQL Tables (tblorder_items and tbldesigns). Both tables store a common field (DesignID). What I want to do is bring up all the records in tblorder_items where OrderID = 1 plus the fields from the tbldesigns table where the DesignID matches the DesignID in tblorder_items.

This is what I've worked out so far:
[code]SELECT tblorder_items. * , tbldesigns.Image1, tbldesigns.DesignName, tbldesigns.Postage
FROM tblorder_items, tbldesigns
WHERE tblorder_items.DesignID = tbldesigns.DesignID
ORDER BY tblorder_items.DesignID
[/code]

At the moment it brings up all records in the tblorder_items table plus the matching details from the tbldesigns table (like it should). So to narrow the search down further and only bring up the records from the tblorder_items table where OrderID=1, do I just add in:
[code] AND tblorder_items.OrderID=1[/code] into the WHERE clause?

Cheers and thanks for all your help,
MMCB
Link to comment
https://forums.phpfreaks.com/topic/35814-sql-query-problem/
Share on other sites

Ok, now I feel dumb.
I've got it working the way it should be, sorry guys.

I do however have another question:
Is there a simple way to convert a list of records into an array?

So array[0] = 1 record, but array[0][0] = field 1 in record 1, array[0][1] = field 2 in record 1, etc...
Does that make sense?

Cheers,
MMCB
Link to comment
https://forums.phpfreaks.com/topic/35814-sql-query-problem/#findComment-169786
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.