I have three tables: employee with id(employee id), numOfTickets tickets with date, asset(id) and some more fields control with id(employee id), asset(id) when a new ticket is created it automatically inserts a row into tickets and control. Now I want to create a Trigger or something similar to automatically …
Tag: mysql
Why does my procedure have error when I’m trying to do loop?
i try to do loop to load data in MySQL Workbench 8.0. but it keep error and i cannot figure it out. here is my code Answer You cant use VARCHAR() in CAST(). You need to change that to CHAR() and with length defined. Try this:
How do I select rows that are not recent and are different from the last entry?
How do I select rows that are not recent and are different from the last entry? We recognize the differences by context field. My example DB: I would like to retrieve from try table rows with id: 4, 7, 8 and 11. I tried the following: But I have got the following error: ERROR 1242 (21000) at line 120: Subquer…
retrieve rows based on parent relationship
This is the query: I am trying to get all the checklist items that have the same item_stock_id from the checklists that have the same ambulance_id. However, the query from above is not working, showing me this error: Below is the ChecklistItem model: And this is the Checklist model: Answer To constrain the ea…
How to deduct sold quantity from stock tables in MySQL
I have two mysql tables. The two tables with the sample data are as follows. By this I want to build up a update query. This should deduct the quantity of the items in the sales table from the stock table. If such a query can be created in mysql it should be updated in ascending order on the stock_id
How to know what the select query took time?
I have 4 queries and I want to compare the time between them, Is there any command to show the time taken for every query? Answer You have can use SHOW PROFILE Statement. Enable it by using: For example, I executed some queries as below:
How can I find all Sites with latest date?
I am trying to add all areas of data that will show all latest pricing. Because there are two latest dates for specific locations, only 5/6 show up with a date of 5/27. I need one location to show up as well as the latest date for it is 5/26. EXAMPLE BELOW: I currently have this query: RESULTS: I need
176. Second Highest Salary
The above-stated query is not working and giving a response as You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘having salary <> max(salary)’ at line 2 As having is used for aggregator functions this should…
Get 2 record of a particular category based on foreignkey value in mysql query?
I have two table product and mastercategory product has columns mastercategory has columns I want to get 2 latest record of each category where is_hotcategory is true How can I get this I tried it with this: I’m getting last record of each category then getting 2nd last record of each category then with…
How to not include duplicates in SQL with inner join?
I’m trying to list the customer’s name, last name, email, phone number, address, and the title of the show they are going. I am not supposed to list duplicate names of the customer, but unfortunately, if 1 customer is seeing different shows, their name appears twice. I am still getting duplicates …