Tag: sql

66 votes
8 answers
775 views
MySQL vs MongoDB 1000 reads

I have been very excited about MongoDb and have been testing it lately. I had a table called posts in MySQL wi

avatar
Jesenia
0 1 0 9
asked 07 September, 2021
61 votes
6 answers
1.8K views
Add new field to every document in a MongoDB collection

How can I add a new field to every document in an existent collection? I know how to update an existing docum

avatar
Keila
0 1 0 9
asked 07 September, 2021
62 votes
11 answers
1.7K views
How do you query for "is not null" in Mongo?

I would like to execute a following query: db.mycollection.find(HAS IMAGE URL) What should be the correct s

avatar
Lorenzo
0 1 0 9
asked 07 September, 2021
53 votes
7 answers
600 views
When to use CouchDB over MongoDB and vice versa

I am stuck between these two NoSQL databases. In my project I will be creating a database within a database.

avatar
Margo
0 1 0 9
asked 07 September, 2021
61 votes
16 answers
2.1K views
DateTime2 vs DateTime in SQL Server

Which one: datetime datetime2 is the recommended way to store date and time in SQL Server 2008+? I'm a

avatar
Hallie
0 1 0 9
asked 07 September, 2021
57 votes
22 answers
2.5K views
How can I get column names from a table in SQL Server?

I want to query the name of all columns of a table. I found how to do this in: Oracle MySQL PostgreSQL But I a

avatar
Emilia
0 1 0 9
asked 07 September, 2021
55 votes
27 answers
2.1K views
How can I list all foreign keys referencing a given table in SQL Server?

I need to remove a highly referenced table in a SQL Server database. How can I get a list of all the foreign

avatar
Thurman
0 1 0 9
asked 07 September, 2021
51 votes
11 answers
2.8K views
How to Join to first row

I'll use a concrete, but hypothetical, example. Each Order normally has only one line item: Orders: Or

avatar
Gigi
0 1 0 9
asked 07 September, 2021
56 votes
14 answers
2.5K views
Should I use != or <> for not equal in T-SQL?

I have seen SQL that uses both != and <> for not equal. What is the preferred syntax and why? I like !=

avatar
Lorenzo
0 1 0 9
asked 07 September, 2021
61 votes
21 answers
1.2K views
How can I SELECT rows with MAX(Column value), PARTITION by another column in MYSQL?

My table is: id home datetime player resource 1 10 04/03/2009 john 399 2 11 04/03/2009 juliet 244 5 12 04/03/

avatar
Lawanda
0 1 0 9
asked 07 September, 2021
57 votes
30 answers
964 views
Exclude a column using SELECT * [except columnA] FROM tableA?

We all know that to select all columns from a table, we can use SELECT * FROM tableA Is there a way to excl

avatar
Patsy
0 1 0 9
asked 07 September, 2021
55 votes
21 answers
1.8K views
Function vs. Stored Procedure in SQL Server

I've been learning Functions and Stored Procedure for quite a while but I don't know why and when I

avatar
Keila
0 1 0 9
asked 07 September, 2021
63 votes
24 answers
2.6K views
Search text in stored procedure in SQL Server

I want to search a text from all my database stored procedures. I use the below SQL: SELECT DISTINCT o.

avatar
Scot
0 1 0 9
asked 07 September, 2021
48 votes
20 answers
614 views
Join vs. sub-query

I am an old-school MySQL user and have always preferred JOIN over sub-query. But nowadays everyone uses sub-qu

avatar
Charis
0 1 0 9
asked 07 September, 2021
61 votes
17 answers
1.2K views
Save PL/pgSQL output from PostgreSQL to a CSV file

What is the easiest way to save PL/pgSQL output from a PostgreSQL database to a CSV file? I'm using Pos

avatar
Dorinda
0 1 0 9
asked 07 September, 2021
54 votes
11 answers
1.1K views
Insert into a MySQL table or update if exists

I want to add a row to a database table, but if a row exists with the same unique key I want to update the row

avatar
Rudy
0 1 0 9
asked 07 September, 2021
63 votes
15 answers
1.4K views
When should I use CROSS APPLY over INNER JOIN?

What is the main purpose of using CROSS APPLY? I have read (vaguely, through posts on the Internet) that cros

avatar
Sena
0 1 0 9
asked 07 September, 2021
54 votes
12 answers
2.7K views
INNER JOIN ON vs WHERE clause

For simplicity, assume all relevant fields are NOT NULL. You can do: SELECT table1.this, table2.that, ta

avatar
Percy
0 1 0 9
asked 07 September, 2021
61 votes
25 answers
3K views
SQL update from one Table to another based on a ID match

I have a database with account numbers and card numbers. I match these to a file to update any card numbers to

avatar
Boyd
0 1 0 9
asked 07 September, 2021
58 votes
30 answers
2.5K views
Parameterize an SQL IN clause

How do I parameterize a query containing an IN clause with a variable number of arguments, like this one? SEL

avatar
Kurtis
0 1 0 9
asked 07 September, 2021