Skip to content

Tag: mysql

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…

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 …