Tag: r

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
57 votes
14 answers
990 views
How do I escape a single quote in SQL Server?

I am trying to insert some text data into a table in SQL Server 9. The text includes a single quote '. Ho

avatar
Kristopher
0 1 0 9
asked 07 September, 2021
54 votes
30 answers
1.2K views
Retrieving the last record in each group - MySQL

There is a table messages that contains data as shown below: Id Name Other_Columns ----------------------

avatar
Janella
0 1 0 9
asked 07 September, 2021
65 votes
14 answers
3.1K views
How do I limit the number of rows returned by an Oracle query after ordering?

Is there a way to make an Oracle query behave like it contains a MySQL limit clause? In MySQL, I can do this:

avatar
Vi
0 1 0 9
asked 07 September, 2021
50 votes
24 answers
1.7K views
Get list of all tables in Oracle?

How do I query an Oracle database to display the names of all tables in it?

avatar
Freida
0 1 0 9
asked 07 September, 2021
57 votes
6 answers
2.6K views
Difference between JOIN and INNER JOIN

Both these joins will give me the same results: SELECT * FROM table JOIN otherTable ON table.ID = otherTable.

avatar
Scot
0 1 0 9
asked 07 September, 2021
60 votes
14 answers
3.1K views
SQL Server - Best way to get identity of inserted row?

What is the best way to get IDENTITY of inserted row? I know about @@IDENTITY and IDENT_CURRENT and SCOPE_IDE

avatar
Dorinda
0 1 0 9
asked 07 September, 2021
65 votes
3 answers
2K views
Using group by on multiple columns

I understand the point of GROUP BY x. But how does GROUP BY x, y work, and what does it mean?

avatar
Dusty
0 1 0 9
asked 07 September, 2021
52 votes
13 answers
2.5K views
Can I concatenate multiple MySQL rows into one field?

Using MySQL, I can do something like: SELECT hobbies FROM peoples_hobbies WHERE person_id = 5; My Output:

avatar
Renaldo
0 1 0 9
asked 07 September, 2021
55 votes
24 answers
1.9K views
How to reset AUTO_INCREMENT in MySQL

How can I reset the AUTO_INCREMENT of a field? I want it to start counting from 1 again.

avatar
Scot
0 1 0 9
asked 07 September, 2021
63 votes
7 answers
2.1K views
What are the options for storing hierarchical data in a relational database?

Good Overviews Generally speaking, you're making a decision between fast read times (for example, nested

avatar
Leonardo
0 1 0 9
asked 07 September, 2021
63 votes
16 answers
2.6K views
How can I do an UPDATE statement with JOIN in SQL Server?

I need to update this table in SQL Server with data from its 'parent' table, see below: Table: sale

avatar
Freida
0 1 0 9
asked 07 September, 2021
63 votes
15 answers
385 views
How can I delete using INNER JOIN with SQL Server?

I want to delete using INNER JOIN in SQL Server 2008. But I get this error: Msg 156, Level 15, State 1, L

avatar
Jefferey
0 1 0 9
asked 07 September, 2021
55 votes
18 answers
1.4K views
Select first row in each GROUP BY group?

As the title suggests, I'd like to select the first row of each set of rows grouped with a GROUP BY. Spec

avatar
Juliane
0 1 0 9
asked 07 September, 2021
57 votes
30 answers
1.9K views
How do I perform an IF...THEN in an SQL SELECT?

How do I perform an IF...THEN in an SQL SELECT statement? For example: SELECT IF(Obsolete = 'N' OR

avatar
Joseph
0 1 0 9
asked 07 September, 2021
49 votes
30 answers
1.3K views
How to query MongoDB with "like"

I want to query something with SQL's like query: SELECT * FROM users WHERE name LIKE '%m%' Ho

avatar
Shanita
0 1 0 9
asked 07 September, 2021
62 votes
30 answers
1.3K views
Insert results of a stored procedure into a temporary table

How do I do a SELECT * INTO [temp table] FROM [stored procedure]? Not FROM [Table] and without defining [temp

avatar
Chelsea
0 1 0 9
asked 07 September, 2021
60 votes
30 answers
2.9K views
How to return only the Date from a SQL Server DateTime datatype

SELECT GETDATE() Returns: 2008-09-22 15:24:13.790 I want that date part without the time part: 2008-09-22 0

avatar
Corrin
0 1 0 9
asked 07 September, 2021