Tag: sql

72 votes
14 answers
2.7K views
How do I see all foreign keys to a table or column?

In MySQL, how do I get a list of all foreign key constraints pointing to a particular table? a particular colu

avatar
Scot
0 1 0 9
asked 07 September, 2021
69 votes
11 answers
2.1K views
MySQL: Grant **all** privileges on database

I've created database, for example 'mydb'. CREATE DATABASE mydb CHARACTER SET utf8 COLLATE ut

avatar
Stacia
0 1 0 9
asked 07 September, 2021
60 votes
8 answers
2.9K views
Create new user in MySQL and give it full access to one database

I want to create a new user in MySQL and give it full access only to one database, say dbTest, that I create w

avatar
Emilia
0 1 0 9
asked 07 September, 2021
60 votes
24 answers
587 views
Find duplicate records in MySQL

I want to pull out duplicate records in a MySQL Database. This can be done with: SELECT address, count(id) a

avatar
Emilia
0 1 0 9
asked 07 September, 2021
60 votes
16 answers
2.1K views
MySQL Error 1093 - Can't specify target table for update in FROM clause

I have a table story_category in my database with corrupt entries. The next query returns the corrupt entries:

avatar
Wei
0 1 0 9
asked 07 September, 2021
62 votes
13 answers
1.8K views
When to use single quotes, double quotes, and backticks in MySQL

I am trying to learn the best way to write queries. I also understand the importance of being consistent. Unti

avatar
Sydney
0 1 0 9
asked 07 September, 2021
52 votes
15 answers
1.5K views
How do I see what character set a MySQL database / table / column is?

What is the (default) charset for: MySQL database MySQL table MySQL column

avatar
Keith
0 1 0 9
asked 07 September, 2021
58 votes
4 answers
2.5K views
SQL injection that gets around mysql_real_escape_string()

Is there an SQL injection possibility even when using mysql_real_escape_string() function? Consider this samp

avatar
Don
0 1 0 9
asked 07 September, 2021
59 votes
15 answers
404 views
MySQL Query GROUP BY day / month / year

Is it possible to make a simple query to count how many records I have in a determined period of time like a y

avatar
Lashawna
0 1 0 9
asked 07 September, 2021
57 votes
10 answers
1.9K views
How can I temporarily disable a foreign key constraint in MySQL?

Is it possible to temporarily disable constraints in MySQL? I have two Django models, each with a foreign key

avatar
Hildegard
0 1 0 9
asked 07 September, 2021
53 votes
7 answers
2.8K views
'IF' in 'SELECT' statement - choose output value based on column values

SELECT id, amount FROM report I need amount to be amount if report.type='P' and -amount if report.

avatar
Keila
0 1 0 9
asked 07 September, 2021
59 votes
30 answers
1.5K views
Disable ONLY_FULL_GROUP_BY

I accidentally enabled ONLY_FULL_GROUP_BY mode like this: SET sql_mode = 'ONLY_FULL_GROUP_BY'; Ho

avatar
Shanita
0 1 0 9
asked 07 September, 2021
60 votes
13 answers
2.5K views
How to truncate a foreign key constrained table?

Why doesn't a TRUNCATE on mygroup work? Even though I have ON DELETE CASCADE SET I get: ERROR 1701 (4

avatar
Hilario
0 1 0 9
asked 07 September, 2021
56 votes
15 answers
1.7K views
How can I do a FULL OUTER JOIN in MySQL?

I want to do a full outer join in MySQL. Is this possible? Is a full outer join supported by MySQL?

avatar
Alba
0 1 0 9
asked 07 September, 2021
59 votes
27 answers
1.5K views
Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server

This should be dead simple, but I cannot get it to work for the life of me. I'm just trying to connect re

avatar
Lawanda
0 1 0 9
asked 07 September, 2021
64 votes
14 answers
752 views
Duplicating a MySQL table, indices, and data

How do I copy or clone or duplicate the data, structure, and indices of a MySQL table to a new one? This is w

avatar
Kisha
0 1 0 9
asked 07 September, 2021
47 votes
26 answers
954 views
Finding duplicate values in MySQL

I have a table with a varchar column, and I would like to find all the records that have duplicate values in t

avatar
Forrest
0 1 0 9
asked 07 September, 2021
59 votes
4 answers
1.2K views
TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT maximum storage sizes

Per the MySQL docs, there are four TEXT types: TINYTEXT TEXT MEDIUMTEXT LONGTEXT What is the maximum length t

avatar
Venice
0 1 0 9
asked 07 September, 2021
47 votes
8 answers
1.3K views
MySQL: Large VARCHAR vs. TEXT?

I've got a messages table in MySQL which records messages between users. Apart from the typical ids and m

avatar
Rudolf
0 1 0 9
asked 07 September, 2021
57 votes
12 answers
677 views
"INSERT IGNORE" vs "INSERT ... ON DUPLICATE KEY UPDATE"

While executing an INSERT statement with many rows, I want to skip duplicate entries that would otherwise caus

avatar
Leonardo
0 1 0 9
asked 07 September, 2021