MySQL Forums
Forum List  »  Newbie

Re: How do I combine 3 queries into one
Posted by: Neil Jensen
Date: April 12, 2009 09:01PM

Hi, Thanks for reply. What is happening, I have laid out here with pictures of my tables.

The item association table is getting three entries for every one item_id entry from the stuff table.

What I would like is to have the item_cat_association table get one primary key id for each item_id, cat_id, sub_id entered from my html form.

The LAST_INSERT_ID() call gives me my item_id inserted correctly for item_id in the item_cat_associations table,

but the other two queries are coming from a drop down menu created by ajax/javascript so I had to use the HTTP_POST_VARS in order to retrieve them from the form to be inserted in the database in the item_cat_associations table.
I hope this is not too confusing, and I thank you for your help.

TABLE
item_cat_associations
id item_id cat_id sub_id
1 1 0 0
2 0 2 0
3 0 0 6
4 2 0 0
5 0 1 0
6 0 0 1
7 3 0 0
8 0 1 0
9 0 0 2
10 4 0 0
11 0 1 0
12 0 0 3
13 5 0 0
14 0 2 0
15 0 0 6
16 6 0 0
17 0 2 0
18 0 0 8



TABLE
category

cat_id category
1 Books
2 Computer
3 Household
4 Clothing

TABLE
subcategory

sub_id subcategory cat_id
1 Text 1
2 Philosophy 1
3 Ethics 1
4 Games 1
5 History 1
6 Software 2
7 Hardware 2
8 Peripherals 2
9 Storage Devices 2

TABLE
stuff

item_id item_name item_url thumb_url item_desc dtime
1 computer stuff http:// http:// 2009-04-12 22:33:06
2 bookb thingy http:/ http:// 2009-04-12 2:33:25
3 big book thingy http:// http:// 2009-04-12 22:33:46
4 big book bigger http:// http:// 2009-04-12 22:34:06
5computer stuff softwarehttp:/ http:// 2009-04-12 22:34:35
6Computer stuff peripherals http:// http:// 2009-04-12 22:34:52

Options: ReplyQuote


Subject
Written By
Posted
Re: How do I combine 3 queries into one
April 12, 2009 09:01PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.