SQL PHP HTML ASP JavaScript articles and free scripts to download
 

SQL INSERT Command with set option

By using set option we can insert record to any table. This is an alternate to insert command using value option of adding single record to the table. Here we have to use insert command at the beginning and use field names along with the value for the files with an equal to symbol. This is help full when we are handling more number of fields with one insert command; we can match the value to field name easily with out worrying about matching the value to field names. In other words we can ensure proper value to the correct column. This is also useful when we are adding value to some fields and allowing default value for other fields. Here is an example of the sql insert command to add a record using set option.

Insert into library set book_name='Learning MySQL', author='plus2net group'

Related Tutorial
SQL Insert using VALUE option

This will add one new record to the table and values for two fields book_name and author gets added in the new record. This is quite helpful in matching field names to value.


Further readings
Changing structur of the table bu alter query
Create table query with if exists sql with php script
Creating a new table by using data from one table
Change the name of a table
Copying data from one table to another table
Delete records from a table with conditinos
Delete table by using DROP sql
Updating another table with data from main table
Update SQL commands
Inserting SUM, AVG data from one table column to other using group by command
Table Records are downloaded as .csv file
anjali vaswani18-01-2011
can set command be also used for checking a value in the field of one column and entering value in other column. example: if we want to enter value of y corresponding to its value o x in table t1 where x and y are columns of table t1 and x value is already entered in the database
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked

Join Our Email List
Email:  
For Email Newsletters you can trust
Modify Table
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2013 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer