Skip to content
Advertisement

Tag: mysql

Checking if two values in Query are the same, makes Query very slow

My Goal: A Query, which provides all provinces, in which a building is constructing. My Problem: As soon as I make sure that every building is compared to the same building (comparing upgrade_id) the Query takes forever. Without the last part of the where statement it takes 1 sec, which is totally fine. Table Setup Provinces change from time to

MySQL Select Count of Duplicate Value In Relation Table

I have 3 tables: foods, order_detail, and orders Here are the records for table foods: Here are the records for table order_detail: And here are the records for orders table: I want to show count order detail grouped by food type. I expected this result: Here is my approach, but it still doesn’t show the expected result. The result is:

I can’t get the correct output when I use / ORDER BY from my SQL example?

I was playing around SQL sample that I wrote and I’m quite surprised that I couldn’t get the correct output when I use less than, greater than or ORDER BY. for example, select player_name, jersey_number from Players order by ‘jersey_number’ desc; it should give players name and jersey number sort descending order from their jersey number. However, this is what

Cant understand my syntax mistake in MySQL CREATE FUNCTION

This is my code and I can not find the mistake! I am trying to create a function that multiplies a value to de input parameter and returns that result! It should not be that difficult but I am not finding my sintaxt mistake The mistake says: error code 1064 Answer The DECLARE has to be before the code. I

Need to fix sorting order by name and price

I am working on school listing project. I have created database name is school and under I add new table name is schoollist Here I have many school. I have added few column on it bellow the list of column. For the above table i want to search Wright Oslo and after the result should be Wright oslo school and

How to show/fetch amount of posts, comments etc a user has made

I want to show the users the amount of posts, comments etc they have created in their profile section, just like any other forums that exist. I am doing this with php and MYSQLI. Post table: I have tried to add another column to the post table and increment its value by 1 each time the user makes a post

Simplifying SQL query

I’m using the Bixi public dataset found at https://www.bixi.com/en/open-data and have been asked to find “the average number of trips a day for each year-month combination in the dataset”. Here’s an example of the table from which I’m querying: id start_date start_station_code end_date end_station_code duration_sec is_member 85843 2016-04-15 00:00:00 6315 2016-04-15 00:05:00 6315 349 1 85844 2016-04-15 17:16:00 6315 2016-04-15

Advertisement