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
_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members