Say I have two tables: Table enterprise: id > integer name > text created_on > date Table contact: id > integer enterprise_id > integer (matching from table Prime) first_name > …
Tag: mysql
mySQL – How can I see which users submitted orders last month but not this month?
I need to figure out the users who submitted orders last month but not this month. This is my current query to count total users, but how can I cross check to see who has bought this month but not the last? This is my the customer orders table this would be the expected output, a list of all the
Something wrong with this SQL query?
Is there something wrong with this query? SELECT id, ( 6371 * acos(cos(radians(?1)) * cos(radians(latitud)) * cos(radians(longitud) – radians(?2)) + sin(radians(?1)) * sin(radians(latitud)))) …
User with multiple companies (different type)
I built an application in Laravel that is a simple CRUD app. Now im struggling with migrations a bit. User belongs to Company. Company can have many users. Company type can be Supplier, Customer or …
Error Code: 3813. Column check constraint ‘customer_details_chk_2’ references other column
CREATE TABLE Customer_Details ( Customer_Id int(4) auto_increment, C_FirstName char(20), C_LastName char(20), PRIMARY KEY (Customer_Id), C_Temperature decimal(5,2), Mail_Id …
Show the manufacturers that sold cellphone in 2010 but didn’t in 2009. (USING MYSQL)
SELECT Manufacturer_Name FROM DIM_MANUFACTURER INNER JOIN DIM_MODEL ON DIM_MANUFACTURER.IDManufacturer = DIM_MODEL.IDManufacturer WHERE DIM_MANUFACTURER.IDManufacturer IN ( …
Failed to add the foreign key constraint. Missing index for constraint * in the referenced table *
system info SHOW VARIABLES LIKE “%version%”; when i create table in database with following statements it sucked. CREATE TABLE flavors ( created_at DATETIME, updated_at DATETIME, …
How to filter record with specific condition?
I have a table called post which contains WordPress posts that have this structure: each zoacres-property post have a meta stored inside the meta table: I’m trying to filter the zoacres-property post by price, and I successfully did this using this query: which returns: this result is correct but, I wou…
Match specific string before user input
I have the following strings: SDZ420-1241242, AS42-9639263, SPF3-2352353 I want to “escape” the SDZ420- part while searching and only search using the last digits, so far I’ve tried RLIKE …
Select last N rows with multiple values in a single query
I have a table: messages: < id – title – body – city – street – building – created on > While I was able to select required messages in multiple queries, I need to do it in a single one: Here are my queries at the moment: I need one query because I can then use ORDER …