Hello,

What's the latest mysql syntax to insert into 2 tables:

   "INSERT INTO student as t, study_report as s(t.group_id, t.access_level_id, t.stu_username, t.stu_fname, t.stu_lname, t.stu_email, t.stu_address, t.stu_telp, t.stu_hp, t.stu_wa, t.stu_skype, t.stu_facebook, t.stu_twitter, s.group_id, s.stu_fname, s.stu_lname) VALUES('".$group_id."','".$access_level_id."', '".$username."', '".$stu_fname."','".$stu_lname."', '".$stu_email."', '".$stu_address."','".$stu_telp."','".$stu_hp."','".$stu_wa."','".$stu_skype."','".$stu_facebook."','".$stu_twitter."', '".$group_id."', '".$stu_fname."','".$stu_lname."')";

I have an error appears:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as t, study_report as s(t.group_id, t.access_level_id, t.stu_username, t.stu_fna' at line 1

Looks like the syntax is incorrect and how to fix it?

You trying to insert into two tables with one INSERT statement.
That won't work without some changes. You can either run two queries separately or insert into one table that has an INSERT trigger on it which will automatically take care of the second insert.
There are probably some more complex ways using temp tables or outputting but I don't see why you would need to go that way.
My advice is to do two queries, wrapping your insertions in a transaction so you can rollback shoudl you need to.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.