This is the query that never finishes: When I run just the subquery, it completes in 12ms and returns two ids. When I hardcode those 2 ids in place of the subquery, the outerquery returns two rows and completes in 0.3ms. As you can see, both parts of the query run incredibly quickly and it’s not like we’re dealing with
Tag: mysql
How to count the number of entries in the list when requesting Select?
I apologize for the possible incorrectness in the presentation, I use a translator. Let’s say there is a users table in which there is an id field. And there is a list that lists the id numbers and some of them are repeated. My query returns the following 3 – 1, 10 – 1. And I would like to get
SQL query counting stats – counting if this is the first record in a table for a particular user
I’m building some basic stats/reporting into a CRM system built in php/mysql. Consider the query: This is working so far to return the desired statistics but I am struggling for the best way to identify new students. For the purposes of this report a new student would be any user_id for whom the current record would be their first entry
SQL: How to select a single row based on a column matched against multiple possible values with preferred match order?
Using MariaDB. Say you have a table, one of the columns is color and is the primary key so it’s unique. I want a select statement to get one row based on color but i want to search for three possible color matches in a preferred order. A normal WHERE color=’red’ OR color=’blue’ OR color=’green’ won’t work because that would
Aggregated row count differences between tables
I have two MySQL tables A and B both with this schema ID entity_id asset asset_type 0 12345 x 1 .. ……… ….. ………. I would like to get an aggregated top 10/50/whatever entity_ids with the largest row count difference between the two tables. I think I could do this manually by just getting the highest row count by entity_id
How to get the last 7 weeks, 7 months date range from current date PHP?
How can I get the date range of last seven weeks /months from the current date, i have already done with last seven days fetch last seven days, weeks and month sales total grouped by 7 particular days, 7 particular weeks and 7 particular months ex: Last seven weeks Last seven Months The below query I have done for last
SQL query to consider exactly last 3 email send count and then return the respective click count
I have a table – ‘clicks_plus_noClicks_raw’ like below If customer has not clicked on any of the last 3 emails we sent(exact 3), I want to add the result to final table with count as 0. a@gmail.com & b@gmail.com should be skipped because we dint send them 3 emails yet.The final results should be only for ones we sent 3
How to print a variable in SQL stored procedure?
I want to print the a variable in the above code. But the code returns How to fix this? Answer You can use an OUT variable ✓ ✓ | answer | | :—– | | yes | db<>fiddle here* Or simply don_’t use INTO or := | count(amount) | | ————: | | 2 | ✓ | answer | |
How to find the category that is both ordered & clicked by customer joining multiple tables?
I have these below 5 tables and I am trying to find customers that ordered from the same category they clicked. With a condition where order date should be greater than the click date Table: customers Table : orders Table : clicks Table : product Table : dim Expected results c@gmail will be excluded because he ordered a different category
How to find out if variable value in database json column Codeigniter?
Im using Codeigniter. Im trying to get some value in database like; the problem is ‘json_value’ column is like = [{“name”:”test1″,”value”:”test1″},{“name”:”test2″,”value”:”test2″}] how can I get ‘test1’ if ‘json_value’ has? Answer You can use LIKE in your query For more information read the CI3 documentation.