INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Can't Create Trigger using values from other tables

Can't Create Trigger using values from other tables

Can't Create Trigger using values from other tables

(OP)
Hi all,

I'm trying my hand at some MySQL. Although I am a seasoned programmer, I have never touched MySQL and I am struggling to create a new trigger using phpMyAdmin.

In short, there are 3 tables, "tblusers" "tblprofile" and "tblfamily". Assuming a user is logged in and they want to create a new profile. Each profile will contain family members. The first family member should be the current user logged in. I am trying to create an after insert trigger on the profile table that takes the "FRIENDLY NAME" from the user table and inserts a new row into the family table, yet the code is throwing the 1064 error.

My code is below:

CODE --> MySQL

BEGIN

DECLARE MYNAME VARCHAR(30);

SET MYNAME = SELECT USR_FRIENDLY_NAME 
             FROM tblusers 
             WHERE USR_ID = ( SELECT PRO_USR_ID 
                              FROM tblprofiles 
                              WHERE PRO_ID = NEW.PRO_ID);

INSERT INTO tblfamily (FAM_PRO_ID, FAM_NAME, FAM_DOB,      FAM_DATE_UPDATED, FAM_USER_UPDATED)
               VALUES (NEW.PRO_ID, MYNAME,   '2017-01-01', NOW(),            1);

END 

I'm sure this will be easily fixed, but Google doesn't seem to be my friend today.

Thanks for any help you can give

TheFitz

Fitz
Did you know, there are 10 types of people in this world:
* Those who understand binary
and
* Those who Don't!!

RE: Can't Create Trigger using values from other tables

Since this is really about MYSQL and has pretty much nothing to do with PHP, I would suggest posting in the forum436: MySQL for better and more accurate help.

----------------------------------
Phil AKA Vacunita
----------------------------------
OS-ception: Running Linux on a Virtual Machine in Windows which itself is running in a Virtual Machine on Mac OSx.

Web & Tech

RE: Can't Create Trigger using values from other tables

(OP)
OK, will do.

Thanks Vacunita

Fitz
Did you know, there are 10 types of people in this world:
* Those who understand binary
and
* Those who Don't!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close