I have quite simple question. I am creating database administration tool, where user will be able to create relations between tables, but I am not sure if table order is important when creating relations. For example: I have two tables ‘user'(user_id(INT, PRIMARY KEY), name(VARCHAR), email(VARCHAR)) and…
Tag: mysql
Calculate total revenue made from each item broken down by country and day
I have a table which consists: id country Date item_name price ae3u2 USA 27/12/2018 budget 1.99 bf5d8 India 31/12/2018 everything 34.99 dc8a4 USA 22/01/2019 cars …
Select query on MYSQL table taking long time and getting timed out
I have a mysql table with 2 million rows, when I’m running any select query on the table it’s taking long time to execute and ultimately it does not return any result. I have tried running select query from both Mysql Workbench and terminal, it’s the same issue happening. Below is the table:…
Using arithmetic operators and/or brackets in a LIMIT clause
I have the following small subquery in query in stored procedure. But there is the syntax error: “(” is not valid at this position, expecting an identifier So, the question is: do I have a possibility to use brackets and/or arithmetic operators in LIMIT clause? Documentation says I can use local v…
Inserting data into a table using foreign keys in MySQL
I am trying to insert data into a contacts table using foreign keys in mysql, the structure of tables are as follows The fk_id in the contacts table is the FOREIGN KEY and it relates to the pers_id PRIMARY KEY in the users table, I am trying to insert a new contact with relates to a user in the users
how to query the max value of count
I try to get the max count value but error this is my data I need to get the max count of tool_id I use this code to get tool_count and I use to get max tool_count but it error the result I need : Answer You can try using order by desc with limit 1
Two results in a row with two columns and group
I am trying to mix multiple results on a single line Here the data example: TOPICS topicID state title 1 A ‘Hello’ 1 B ‘Bye’ 2 A ‘Great’ …
count() results without using group by
I am attempting something very similar to last example (Using GROUP BY) on this page: https://thecodedeveloper.com/mysql-count-function/ Referring to the following table of data: The following query: Will produce the following output: Except I want to see the number of employees in each department as well as …
How to structure the database to avoid duplicates in a table
I am doing this exercise where I have to build an sql database (MySql) to store information on private lessons offered by teachers. These are the rules: There is just one predifined week with slot times from Monday to Friday (15-19) Each teacher can teach 1 or more courses Each course can be teached by multip…
How can I echo the position number of SQL row in PHP?
Before you misread the title… I’m not asking how to echo the number of rows, I’m simply looking to find the position that the row is in. Let’s say we have five total rows: Now I’d like to get the position of the row that contains the post ID of 718. From looking at the data, we c…