Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is my INSERT statement good ANSI_SQL

Status
Not open for further replies.

DJDaveMark

Programmer
Feb 19, 2006
8
FR
Hi all,

Being a Java Programmer it's the first time I've designed a database and the queries. I just wondered if the following was ANSI_SQL or if I've added mySQL specific stuff. A quick yes or no would suffice. Any links would be much appreciated.
Code:
START TRANSACTION;
INSERT INTO `race` (
 `time`
)VALUES(
 100000
);

INSERT INTO `stats` (
 `race_id`, `m_stat`, `t_stat`, `r_stat`
)VALUES(
 @lastID:=LAST_INSERT_ID(), 1, 1.1, 14
),(
 @lastID, 2, 1.2, 14
),(
 @lastID, 3, 1.0, 13
),(
 @lastID, 4, 1.1, 14
);

INSERT INTO `lineup` (
 `race_id` , `person_id`
)VALUES(
 @lastID, 1
);
COMMIT;
using the following tables
Code:
+-------+    +-----------+    +-----------+    +---------+
¦person ¦    ¦   lineup  ¦    ¦    race   ¦    ¦  stats  ¦
+-------+    +-----------+    +-----------¦    +---------+
¦  id   ¦   /¦     id    ¦\   ¦     id    ¦   /¦   id    ¦
¦ fname ¦----¦ person_id ¦----¦    time   ¦----¦ race_id ¦
¦ lname ¦   \¦  race_id  ¦/   +-----------+   \¦  m_stat ¦
+-------+    +-----------+                     ¦  t_stat ¦
                                               ¦  r_stat ¦
                                               +---------+
 
Use of ` is not ANSI SQL compliant.

@lastID:=LAST_INSERT_ID() is not ANSI SQL compliant.

@ is not a valid character in an identifier.

LAST_INSERT_ID is a Mysql specific routine.

; is only used as delimiter between statements, not as a terminator.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top