Getting the final value to this MySQL query...
Posted
by Jack W-H
on Stack Overflow
See other posts from Stack Overflow
or by Jack W-H
Published on 2010-04-03T21:05:31Z
Indexed on
2010/04/03
21:13 UTC
Read the original article
Hit count: 250
I've got my database set up with three tables - code, tags, and code_tags for tagging posts. This will be the SQL query processed when a post is submitted. Each tag is sliced up by PHP and individually inserted using these queries.
INSERT IGNORE INTO tags (tag) VALUES ('$tags[1]');
SELECT tags.id FROM tags WHERE tag = '$tags[1]' ORDER BY id DESC LIMIT 1;
INSERT INTO code_tags (code_id, tag_id) VALUES ($codeid, WHAT_GOES_HERE?)
The WHAT_GOES_HERE? value at the end is what I need to know. It needs to be the ID of the tag that the second query fetched. How can I put that ID into the third query?
I hope I explained that correctly. I'll rephrase if necessary.
© Stack Overflow or respective owner