Categories, whilst only displaying the category title once. I have one table that holds the category title (the parent) and the second table which holds the sub-category information. Although when …
Tag: mysql
MySQL: select row only where closest to date has column value
I want to return all rows that were public in May (2019-05), so if a row was turned to draft (and not back to public) at any point before the end of May, I don’t want it. For example: id | post_id | …
How to get the Exact Batch ID from stock table on the basis of Expiry Date?
I want to get the batch id from stock table on the basic of fifo expiry date. How to get it. I write a query it give the exact batch but batch id not accurate. Basically I want to Fetch the batch is …
Count total running events per year with events that range over multiple years
I have a table of events that span over several years. title start_year end_year Event 1 1976 1983 Event 2 1977 2002 Event 3 2018 2019 Event 4 2003 2019 …
How to query MYSQL table to get counts of column occurrence overall and within past year?
I am using MySQL and want to create a query that will count how many times appointments happened per contact_id within the last year, last year, and how many times the occurrence happened overall. …
MySQL Grouping using group_concat and then Group BY
I have a table like this: Basically, I want to group all names and give the count of such groupings like: Since there are 2 users with cooking and cleaning, 1 for washing and 4 for cooking. I am …
Mysql procedure does not execute as expected
Using mysql 5.7, when I execute this procedure: DELIMITER $$ CREATE PROCEDURE tres() BEGIN DECLARE maxid INT; DECLARE x INT; SET maxid = 655; SET x=1; WHILE x<= maxid DO …
Mysql how to orderby matching query string with Full-Text Searches MATCH AGAINST
Ex I have table: Id Name 1 bcd def abc 2 def abc 3 abc I search by Boolean Full-Text Searches like SELECT * FROM table WHERE MATCH (name) AGAINST (‘abc*’ IN BOOLEAN MODE) how to order by if abc …
How to declare a variable holding select query result in a stored procedure?
I have a MySql stored procedure in which I have a variable which will hold the result of a select query. But I am unable to use the variable, as I believe one must declare variables with their data types in a stored procedure. This is a snippet of what I’m trying to do: I’m getting a syntax error …
How to write a query that gives the names of everyone who does not own a blue house?
Q. Write a query that gives the names of everyone who does not own a blue house. Here is my code: SELECT persons.name FROM persons JOIN houses ON (persons.id=houses.owner_id) WHERE houses.color<&…