lcy Posted October 15, 2009 Share Posted October 15, 2009 Hi. I'm using php and mysql for a system. I have some questions on INSERT query. When we are using INSERT, in our query.... i. Is it necessary to include each field included in the table we are going to insert value with (though some of the field maybe do not inserted with value) ? ii. Have to follow the sequence of the fields in database table? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/177763-solved-sql-insert-question/ Share on other sites More sharing options...
Mchl Posted October 15, 2009 Share Posted October 15, 2009 You can (and I dare say - you should) list the fields after table name INSERT INTO tablename (field2,field6,field4) VALUES (v2,v6,v4); Quote Link to comment https://forums.phpfreaks.com/topic/177763-solved-sql-insert-question/#findComment-937331 Share on other sites More sharing options...
farkewie Posted October 15, 2009 Share Posted October 15, 2009 To elaborate they do not have to be in the same order as the database schema and you do not need to list all fields, only ones you want to modify Quote Link to comment https://forums.phpfreaks.com/topic/177763-solved-sql-insert-question/#findComment-937364 Share on other sites More sharing options...
Mchl Posted October 15, 2009 Share Posted October 15, 2009 Yeah... that's what I was trying to hint using numbers next to names Quote Link to comment https://forums.phpfreaks.com/topic/177763-solved-sql-insert-question/#findComment-937497 Share on other sites More sharing options...
lcy Posted October 18, 2009 Author Share Posted October 18, 2009 Thanks. I get what you guys mean Quote Link to comment https://forums.phpfreaks.com/topic/177763-solved-sql-insert-question/#findComment-938933 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.