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

  • SEARCH
  • Home
  • 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 8841453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:43:17+00:00 2026-06-14T10:43:17+00:00

I have the following three (InnoDB-) tables in a MySQL database: Entity (DLID) Category

  • 0

I have the following three (InnoDB-) tables in a MySQL database:

Entity (DLID)
Category (CatID, CatName)
hasCategory (DLID, CatID)

Now, upon insertion into the table hasCategory I would like to make sure, that each Entity is associated with at least one Category. Thus, I wrote the following trigger:

delimiter |

create trigger Max before insert on hasCategory for each row begin
    if  (exists (select distinct DLID from Entity where not exists (select distinct new.DLID from new))) then
        signal sqlstate '45000'
            set message_text = 'Min of 1 category per entity required';
    end if;
end|

delimiter ;

Now, when I execute the following query: insert into hasCategory values (1, 1); I get the error error code 1146: table mydb.new does not exist. I have created some other triggers similar to this one, also referring to the new-table, where it worked perfectly well. Yet, I don’t get it, what causes the error in this particular trigger.

Is it possible that the select statement causes some trouble? I’ve read that only select into statements are valid in procedures, but I don’t know if this has got anything to do with this.

Thanks for your help!

  • 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-14T10:43:18+00:00Added an answer on June 14, 2026 at 10:43 am
    select distinct new.DLID from new
    

    there is no table new in your DB just as the error states. You can use NEW for the record that will be inserted in your trigger but you cannot use it as a table name and select from it.

    try

    if (select 1 from Entity where DLID = new.DLID) = 1 then
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three mysql table from same database Db1. Three tables have following columns.
I have three MySQL InnoDB tables: Debtors Companies Private individuals Now I would like
Here's some background info. I have three MySQL tables (all InnoDB). The first table
I have the following three tables in a database: Products ******** id title artist_id
I am having issues with an InnoDB mysql database. E.g., I have two tables,
I have the following three tables. I am trying to inter link (join) among
I have the following three tables which I am trying to perform a query
In one of my MySQL tables, I have following columns: Skills varchar(80) Industry varchar(40)
I have the following three tables: Item Code ItemCode (many to many relationship between
I have a question about MySQL InnoDB. For example: I have the following table

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.