我必须使用其他 table 字段插入数据 USING PHP
I have to insert data with the other table field USING PHP
请在下面找到插入数据的查询,但在 h_id
字段中,我必须插入另一个 table 字段 id
我必须从 [=15= 获取的所有变量值] 方法
INSERT INTO m_d_details(h_id, name, h_name, surname, village, resi,
mobile_no)VALUES('SELECT id from head_family ORDER BY id DESC LIMIT 1',
'$mname', '$mhname', '$msurname', '$mvillage', '$maddress', '$mno')
尝试:
INSERT INTO m_d_details
(h_id,
name,
h_name,
surname,
village,
resi,
mobile_no)
SELECT id,
'$mname',
'$mhname',
'$msurname',
'$mvillage',
'$maddress',
'$mno'
FROM head_family
ORDER BY id DESC
LIMIT 1
您可以 select 查询中的文字:
INSERT INTO m_d_details
(h_id, name, h_name, surname, village, resi, mobile_no)
SELECT id, '$mname', '$mhname', '$msurname', '$mvillage', '$maddress', '$mno'
FROM head_family
ORDER BY id DESC LIMIT 1)
请在下面找到插入数据的查询,但在 h_id
字段中,我必须插入另一个 table 字段 id
我必须从 [=15= 获取的所有变量值] 方法
INSERT INTO m_d_details(h_id, name, h_name, surname, village, resi,
mobile_no)VALUES('SELECT id from head_family ORDER BY id DESC LIMIT 1',
'$mname', '$mhname', '$msurname', '$mvillage', '$maddress', '$mno')
尝试:
INSERT INTO m_d_details
(h_id,
name,
h_name,
surname,
village,
resi,
mobile_no)
SELECT id,
'$mname',
'$mhname',
'$msurname',
'$mvillage',
'$maddress',
'$mno'
FROM head_family
ORDER BY id DESC
LIMIT 1
您可以 select 查询中的文字:
INSERT INTO m_d_details
(h_id, name, h_name, surname, village, resi, mobile_no)
SELECT id, '$mname', '$mhname', '$msurname', '$mvillage', '$maddress', '$mno'
FROM head_family
ORDER BY id DESC LIMIT 1)