Skip to content
Advertisement

Tag: mysql

Error Code: 1242. Subquery returns more than 1 row in Attribute Subquery

I’m trying to get the difference between two dates deathtime and admittime using subquery in attribute list. This is the script that I run: It returns Error Code: 1242. Subquery returns more than 1 row when I run it. Would really appreciate any help. Answer The reason why you’re getting that error is because a subquery can’t return more than

Select all ID’s that have overlapping timestamp values

Given this table, I’m trying to select all of ids that have an overlapping start_time and end_time grouped by ID. In this case, the table has multiple Ids that may or may not have multiple entries. (In this case, id’s 1 and 2 don’t have multiple rows, whereas 0 does.) Is there a way to retrieve all Ids that have

SQL Trigger for updating values from a query by id

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 update the number of open tickets for each employee. A Query

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 work IMO. Please help me out by explaining

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 union combining both the search query

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 despite using DISTINCT and GROUP BY. What should I

Advertisement