Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8867089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:56:38+00:00 2026-06-14T16:56:38+00:00

I am trying to create a mysql trigger using MAMP for a joomla2.5 application.

  • 0

I am trying to create a mysql trigger using MAMP for a joomla2.5 application.
My trigger:

CREATE TRIGGER `getDivision` BEFORE INSERT ON `encex_autoschedGames`
FOR EACH ROW BEGIN

select division into @div_a from encex_autoschedTeams where team_name = new.team_a; 
set new.division = @div_a;

END

I keep getting the following error:

Column 'division' cannot be null

The story:

I have two tables: 1) Games 2) Teams.
Teams has columns ‘team_name’ and ‘division’
Games has coloumns ‘team_a’, ‘team_b’, and ‘division’

Sample Tables:

Teams table:

Team_name, Division
"team1","A"
"Team2","A"
"Team3","A"
"Team4","A"
"Team5","B"
"Team6","B"
"Team7","B"
"Team8","B"

For the games table, I want the division to come from the Teams table.. So when I insert Team1 Vs Team2 it auto fills the division as A.

Games Table:
Team_a, Team_b, Division
"Team1", "Team2", "A"

I’d like to create a trigger so that when a row is created in the games table it fills the division column with ‘division’ from the ‘Teams’ table where team_name = team_a.

Ideally I’ll build it so it ensures division is the same for both team_a and team_b, but I figure small steps are best here.

After some debugging, I believe my error is in the:
select division into @div_a from encex_autoschedTeams where team_name = new.team_a;

for some reason, the where clause is returning null. After some command line testing, it shouldn’t be. Maybe New.team_a isn’t right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:56:39+00:00Added an answer on June 14, 2026 at 4:56 pm

    The original code works perfectly. The problem was due to to parsing a string earlier on in the code and leaving a difficult to see space in the string of team_names. The query was returning null because it wasn’t matching “team1″ to ” team1″.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a simple Before Insert MySQL Trigger, to check if any
I am trying to create a trigger wherein it will insert a new row
I am trying to create a table in MySql using php. My code looks
Im trying to create a iPhone Objective C login page using PHP/MySQL to authenticate.
I'm trying to create pagination for search results using MySQL and ColdFusion. My intention
I´m trying to create a trigger on MySQL but I´m having a syntax problem,
With MySQL 5.1.43. I am trying to create a trigger like this: USE `databaseA`;
I am trying to create an update trigger in MySQL Community Server 5.5.16. I
I am trying to create an update trigger in MySQL Community Server 5.5.16 but
Hi i'm trying to create below trigger CREATE TRIGGER TRIGBEFORE INSERT ON employee FOR

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.