只想在另一个表中插入一行

时间:2014-02-28 11:34:25

标签: php mysql

如何通过使用引用将选定的字段插入到另一个表中,以便只插入一行数据?

到目前为止,我只能在phpmyadmin

中使用语句时获取所有传输的字段
$Reference=$_GET['Reference'];

$sql="INSERT INTO Triage (Reference, Forename) 
SELECT Reference, Forename from `Instruction` WHERE Reference='$Reference'"

2 个答案:

答案 0 :(得分:0)

INSERT INTO Table2(LongIntColumn2,CurrencyColumn2) 选择LongIntColumn1,Avg(CurrencyColumn)作为CurrencyColumn1 FROM Table1 GROUP BY LongIntColumn1;

INSERT INTO prod_detail(prod_name,prod_code)选择Name,Zip作为来自info_tb的数据,其中Name =" mittal&#34 ;;

答案 1 :(得分:0)

尝试这样的事情:

$Reference=mysql_real_escape_string($_GET['Reference']);

$sql="INSERT INTO Triage (Reference, Forename)  
SELECT Reference, Forename FROM `Instruction` 
WHERE Reference='$Reference' LIMIT 1";