Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
mysql_query("INSERT INTO index (author,heading,description) SELECT author, heading, description FROM posts WHERE heading=".$_GET["val"]."");

This Query is not working.
Posted

1 solution

SQL
INSERT INTO FirstTable (id,name,ClassType)
SELECT id,name,ClassType FROM secondTableName
Where id = values


In sql you can use top 1 for getting only one record if you would get more than one record s using the where condition,

SQL
INSERT INTO FirstTable (id,name,ClassType)
SELECT top 1 id,name,ClassType FROM secondTableName
Where id = values



Thanks
Bimal
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900