okay guys, this is a big one that’s confusing as hell. I’m creating a forum type dealio: I have an array of Topics and each topic has an array of Posts associated with the Topic. The Topics list page should show the latest Post from that specific Topic. (Each topic is in a category as well) Topic Latest post …
Tag: mysql
get users that did not buy a product
I have three tables users table +————————–+————–+——+—–+———+—————-+ | Field | Type | Null | Key | Default | Extra | …
Limit MYSQL search results to dates greater than variable
I have a MYSQL table posts which contains a VARCHAR(25) column created that is filled with datetimes in the format XXXX-XX XX:XX:XX. I’m attempting to search by dates > now – 24 hours. When searching with just one posts.uuid I get the desired result, which lists all posts from that uuid that ar…
How to find whether the same customers who ordered this month also ordered the next month?
I have an orders table Now I want to find how many of the users ordered in 1st month also ordered in the next month. In this case, user_id’s 32,24,27 ordered in 7th month but only 24 and 32 ordered in the next month. I want the result to be like : I’m lost here. Can someone please help me
MySQL: How to sum on joined queries (subqueries) with multiple conditions?
I have two tables: Table Y: indicates over what time period money is valid +———–+———+——+ | starttime | endtime | name | +———–+———+——+ | 1 | 2 | Mark | | …
Query puzzle – how can I select values with fallbacks?
I have a table with 6 columns as follows: CREATE TABLE `test_table` ( `id` bigint UNSIGNED NOT NULL, `A` varchar(255) NOT NULL, `B` varchar(2) NOT NULL, `C` varchar(50) DEFAULT NULL, `D` …
SQL query to count the number of rows in different columns with group by clauses
In my Mysql database, I have 2 columns that store the start and end date of the process, respectively. I need to write a query that allows me to count the number of rows for each month in each column, …
SQL Join tables with no unique values
I am trying to create a table for a game that shows some player and team stats so I can compare them. The two tables look like this: year player team patch game result …
When issuing a command to MySQL, I’m getting that error “#1075 – Incorrect table definition;”
CREATE TABLE onscreen( id int(2) not null AUTO_INCREMENT, subject varchar(100) not null, content varchar(100) not null, date datetime not null );
Is there a way to return non existent values when using groupby and union all?
I have a table that I’m trying to return summarized results from for a chart that will have two datasets, one for debit transactions that have happened each month and one for payments that have happened each month. The table I’m querying looks like this: What I’m looking to get back out of m…