I have/need a table with just an id (news_id) no other fields are required. I need that id for inserts in another table. What is the best way to do an insert in that table.
Thank you in advance
I have/need a table with just an id (news_id) no other fields are required. I need that id for inserts in another table. What is the best way to do an insert in that table.
Thank you in advance
[quote=“donboe, post:1, topic:192977, full:true”]What is the best way to do an insert in that table.[/quote]with an INSERT statement
INSERT
INTO daTable
( id )
VALUES ( 937 )
Hi Rudi. L.M.A.O. Ofcource I understand that I need an insert statement. The id’s are AUTO_INCREMENT. I simply don’t have another field in that table. Should I use a fake field?
May I ask you what exactly you are doing?
I have a site in two languages. The two languages (nl and en) need to be linked to the just added news item
So first I have a insert in a table news. Within that method I return the lastInserId which I use in the follow up inserts (table news_content) for the two languages
If I understood correctly, what I would do is create the tables in this fashion:
news_table
----------
news_id | news_title | news_content | lang_id (this refers to lang_table.lang_id)
lang_table
----------
lang_id | lang_code (e.g en_US)
And then query the news for selected lang based on the lang_id.
Not sure if this is what you were trying to do. Table with just ID field kind of sounds something is not right.
[quote=“donboe, post:3, topic:192977, full:true”] I simply don’t have another field in that table. Should I use a fake field?[/quote]no!
keep the auto_increment, and insert this way –
INSERT
INTO daTable
( id )
VALUES ( NULL )
then continue with your LAST_INSERT_ID()
Thanks Rudi
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.