can any one tell me how to use insert and select statement together with in a same table in mysql.my query is this
but it will return more than one rows inserted.but when i try this
where id = 2;
it will return 0 row inserted .
my php code is this
$sql="INSERT into alumnireg(id,Fname,Mname,Lname,Email,Password)
select '','$fname','$mname','$lname','$email','$pass'
from alumnireg where Email = '$email' AND Password = '$pass'";
$result =mysql_query($sql);
confirm_query($result);
select '','$fname','$mname','$lname','$email','$pass'
from alumnireg where Email = '$email' AND Password = '$pass'";
$result =mysql_query($sql);
confirm_query($result);
Jeetendra GundPosted Jan 21, 2014, 2:09 AM
$sql="INSERT into alumnireg(id,Fname,Mname,Lname,Email,Password)
select '','$fname','$mname','$lname','$email','$pass'
from alumnireg where Email = '$email' AND Password = '$pass'";
$result =mysql_query($sql);
confirm_query($result);
Remove that comma(,) and try.
Biswa Pujarini MohapatraPosted Jan 21, 2014, 1:47 AM
I think you are looking to retrieve last inserted record using MySQL
check this thread
http://php.net/manual/en/function.mysql-insert-id.php
waseem shaikhPosted Jan 21, 2014, 1:22 AM
first insert a data in a table then i just retrieve that data but same table
Jaganathan BantheswaranPosted Jan 21, 2014, 1:15 AM
Do you want to insert data from another table regardless of condition [just copy all the data] or want to insert data only on some condition?
What you want exactly?