Skip to content

Programming Articles

  • HOME
  • Python
  • JavaScript
  • C/C++
  • Java
  • Terms & Conditions and Privacy Policy
  • About US
Main Menu

MYSQL

DB-SQL/Postgresql/MongoDB / MYSQL

INSERT statement conflicted with the FOREIGN KEY constraint in SQL server?

Sample query: I am getting the following error. Could you please help me? Msg 547, Level 16, State 0, Line 1The INSERT statement conflicted with the FOREIGN KEY constraint “FK_Sup_Item_Sup_Item_Cat”. …

INSERT statement conflicted with the FOREIGN KEY constraint in SQL server? Learn More
MYSQL

How to retrieve the last record in each group in MySQL?

MySQL 8.0 now supports windowing functions, like almost all popular SQL implementations. With this standard syntax, we can write greatest-n-per-group queries: Below is the original answer I wrote for this …

How to retrieve the last record in each group in MySQL? Learn More
MYSQL

How do I escape a single quote in SQL Server?

Single quotes are escaped by doubling them up, just as you’ve shown us in your example. The following SQL illustrates this functionality. I tested it on SQL Server 2008: Results …

How do I escape a single quote in SQL Server? Learn More
MYSQL

What’s the difference between utf8_general_ci and utf8_unicode_ci?

For those people still arriving at this question in 2020 or later, there are newer options that may be better than both of these. For example, utf8mb4_0900_ai_ci. All these collations are for the …

What’s the difference between utf8_general_ci and utf8_unicode_ci? Learn More
MYSQL

What are Clustered and Non-Clustered index in SQL server

What are clustered and non-clustered indexes in SQL server? With a clustered index the rows are stored physically on the disk in the same order as the index. Therefore, there …

What are Clustered and Non-Clustered index in SQL server Learn More
DB-SQL/Postgresql/MongoDB / MYSQL

What is the difference between “INNER JOIN” and “OUTER JOIN” in SQL? [Answered]

Query: What is the difference between “INNER JOIN” and “OUTER JOIN”? Also, how do LEFT JOIN, RIGHT JOIN and FULL JOIN fit in? What is the difference between “INNER JOIN” and “OUTER JOIN”? Answer #1: …

What is the difference between “INNER JOIN” and “OUTER JOIN” in SQL? [Answered] Learn More
Java / MYSQL

How to connect Java to a MySQL database? [Answered]

Query explained: How do you connect to a MySQL database in Java? When I try, I get Or Or How to connect Java to a MySQL database? Answer #1: Here’s …

How to connect Java to a MySQL database? [Answered] Learn More
Formatted Codes / MYSQL

How to retrieve the last record in each group – MySQL [Answered]

Sample problem: There is a table messages that contains data as shown below: If I run a query select * from messages group by name, I will get the result as: What query …

How to retrieve the last record in each group – MySQL [Answered] Learn More
DB-SQL/Postgresql/MongoDB / MYSQL

Simulating group_concat MySQL function in Microsoft SQL Server 2005? [Answered]

Query explanation: I’m trying to migrate a MySQL-based app over to Microsoft SQL Server 2005 (not by choice, but that’s life). In the original app, we used almost entirely ANSI-SQL compliant statements, …

Simulating group_concat MySQL function in Microsoft SQL Server 2005? [Answered] Learn More
Formatted Codes / MYSQL

How to return pivot table output in MySQL? [Answered]

Sample problem: If I have a MySQL table looking something like this: company_name action pagecount ——————————- Company A PRINT 3 Company A PRINT 2 Company A PRINT 3 Company B …

How to return pivot table output in MySQL? [Answered] Learn More
Bug fixes / MYSQL

Syntax error due to using a reserved word as a table or column name in MySQL [Answered]

Sample Problem: I’m trying to execute a simple MySQL query as below: But I’m getting the following error: ERROR 1064 (42000): You have an error in your SQL syntax; check …

Syntax error due to using a reserved word as a table or column name in MySQL [Answered] Learn More
Formatted Codes / MYSQL

How to select only rows with max value on a column in SQL [Answered]

Problem: I have this table for documents (simplified version here): id rev content 1 1 … 2 1 … 1 2 … 1 3 … How do I select one …

How to select only rows with max value on a column in SQL [Answered] Learn More
Formatted Codes / MYSQL / PHP

mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc.. expects parameter 1 to be resource [Solutions]

Problem: I am trying to select data from a MySQL table, but I get one of the following error messages: mysql_fetch_array() expects parameter 1 to be resource, boolean given This …

mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc.. expects parameter 1 to be resource [Solutions] Learn More
How To / MYSQL

When to use single quotes, double quotes, and backticks in MySQL [Answered]

Problem: I am trying to learn the best way to write queries. I also understand the importance of being consistent. Until now, I have randomly used single quotes, double quotes, …

When to use single quotes, double quotes, and backticks in MySQL [Answered] Learn More

Featured Posts

From UNIX to Linux – History of Linux

21st November 202010th September 2022

Best themes for Ubuntu: Make Ubuntu Beautiful

20th October 202010th September 2022

Strings in Python

12th September 202010th September 2022

Is Python hard to learn? Top best learning resources

18th April 202010th September 2022

Recent posts

  • How to pad a string with zeroes to the left?
  • What is the difference between process and thread?
  • How to generate a random alpha-numeric string in Java?
  • How to auto-resize an image to fit a ‘div’ container?
  • How to get a Docker container’s IP address from the host?
  • How to display a JavaScript object?
Copyright © 2023 Programming Articles.
Powered by WordPress and HitMag.