Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Insert User row
- INSERT INTO
- `USER`
- (
- `name`,
- `contactNumber`,
- `email`,
- `password`,
- `salt`,
- `gender`
- )
- VALUES
- (
- ?,
- ?,
- ?,
- ?,
- ?,
- ?
- );
- #store the id of the user
- SET @USER_id=LAST_INSERT_ID();
- #insert the users address
- INSERT INTO
- `ADDRESS`
- (
- lineOne,
- postcode
- )
- VALUES
- (
- ?,
- ?
- );
- #store the id of the users address
- SET @ADDRESS_id = LAST_INSERT_ID();
- #Insert row in linking table to link the address amd the user
- INSERT INTO
- USER_ADDRESS
- (
- USER_id,
- ADDRESS_id
- )
- VALUES
- (
- @USER_id,
- @ADDRESS_id
- );
- #link user to a group
- INSERT INTO
- USER_GROUP
- (
- USER_id,
- GROUP_id
- )
- VALUES
- (
- @USER_id,
- #sub query to find group id
- (
- SELECT
- id
- FROM
- GROUP
- WHERE
- name=?
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement