Email address obfuscation in effect -- please
click here to turn it off.
[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
>mehmood hasan wrote:
>>hi
>>i am inserting values from table "marksquery" to table "chemistry"
>>in descendig order by the query m_marks and select only values of subjects
>>= "CHM" by the query
>>
>>mysql_query("INSERT INTO chemistry
>>(f_name,l_name,m_marks,province,subjects,id) select
>>markstable.f_name,l_name,m_marks,
>>province,subjects,id from markstable where subjects = 'CHM' order by
>>m_marks ASC");
>>
>>this query is working well but i want to insert only 10 rows from table
>>"marksquery" to table "chemistry" i defined check for this and also
>>defined loop as
>>for($i=1; $i<=10; $i++)
>>{
>>mysql_query("INSERT INTO
>>chemistry(f_name,l_name,m_marks,province,subjects,id) select
>>markstable.f_name,l_name,m_marks,
>>province,subjects,id from markstable where subjects = 'CHM' order by
>>m_marks ASC");
>>
>>but this not works and it insert all the rows of subjects ="CHM" from
>>table "marksquery" to table "chemistry"
>>I want to insert only First 10 rows.Any one can help me
>>regards
>>
>
>It looks like you're selecting values and inserting them in one swoop --
>MySQL is executing both commands at once as far as your program is
>concerned. You need to separate the SELECT statement from your INSERT
>statement if you want to use for() loops in your program for inserting;
>that also means that all selected values are returned to the program and
>you'll be inserting them one by one.
>
>--
>MK
hi
according to ur opinion i made the select and insert process saperate like
that
$ins = "select * from markstable where subjects = 'CHM' and province = 'P'
order by m_marks desc limit 10";
$insert = mysql_query($ins);
it works well
but in next step i want to insert that selected values from array to table
"chemistry" like that
while ($row=mysql_fetch_array($insert))
{
for($i=1; $i<=10; $i++)
{
mysql_query ("INSERT INTO chemistry
(f_name,l_name,id,m_marks,province,subjects) values
($row[f_name],$row[l_name],$row[id],$row[m_marks],$row[province],$row[subjects])");
}
}
but this step does not work and failed to insert values in table
"chemistry".... can I insert values from array to table
please tell me how
thanx
mehmood
_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
http://join.msn.com/?page=features/virus
_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members