SQL Articles

Page 3 of 12

How to Compare Rows and Columns in the Same Table in SQL

SQL
Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 22-Nov-2024 475 Views

It is not uncommon in SQL to analyze tables vertically or horizontally in an attempt to obtain a solution. This might include establishing a baseline for evaluating successive states, determining boolean variables, or even classifying information without requiring joins over distinct tables. In this article, we explain relevant similarities with examples. Setting Up the Database Let us set up a database with a sample table to illustrate the processes involved in the case studies, this setup will feature the insertion of dummy values to test comparisons. First of all, create a database using the CREATE DATABASE statement − CREATE DATABASE ...

Read More

SQL Query to Compare Two Dates

SQL
Pankaj Kumar Bind
Pankaj Kumar Bind
Updated on 21-Nov-2024 385 Views

Working with dates in SQL can be challenging, especially for beginners. We need to make sure that the format of the date values are consistent throughout the queries, whether you're dealing with simple DATE types or complex DATETIME values. This article will walk you through the process of comparing two dates using different approaches, including examples and outputs, ensuring clarity and understanding. In SQL dates are typically stored in DATE or DATETIME format and to compare two dates, we can use comparison operators such as − =: Checks if two dates are equal. : Checks if one date is ...

Read More

SQL Query to Delete Duplicate Rows

SQL
Mithlesh Upadhyay
Mithlesh Upadhyay
Updated on 20-Nov-2024 273 Views

While working with a database to avoid duplicates, we should follow certain practices when we create the database table. Define primary key to identify rows cluster and non-cluster indexes. Use constraints for data integrity in performance. Database tables may have duplicate rows after following best practices. These duplicate rows create issues while we retrieve data from the database. So we must ensure unique database rows. To do so, first of all, we need to verify whether a table has duplicate rows, If duplicate rows exist, we must remove them by altering the table data. This article will ...

Read More

Authentication Bypass using SQL Injection on Login Page

SQL
Guruchandhran M
Guruchandhran M
Updated on 05-Nov-2024 742 Views

SQL Injection is a common security vulnerability. It occurs when an attacker manipulates a web application's database queries by injecting malicious SQL code. One of the most critical areas for SQL Injection exploitation is the login page of an application. When a user enters their credentials, these inputs are typically used to construct a database query to verify the user’s identity. If the application does not properly sanitize these inputs, an attacker can bypass authentication by injecting SQL statements that modify the intended query, granting them unauthorized access. What is SQL Injection? SQL injection is a code injection technique that ...

Read More

How to Get the names of the table in SQL

SQL
guru
guru
Updated on 01-Nov-2024 380 Views

In SQL databases, it is often necessary to retrieve the list of table names within a database to understand the structure or to perform the certain operations. Each SQL-based database system offers specific ways to query its metadata to extract the table names. In this article, we will explore how to get the names of tables in popular relational database systems including the MySQL, SQL Server, PostgreSQL and Oracle. We will cover the built-in SQL queries and functions that are commonly used for this task. Need to Retrieve Table Names? Database Exploration: When working with ...

Read More

SQL Query to Convert VARCHAR to INT

SQL
guru
guru
Updated on 25-Oct-2024 2K+ Views

In SQL, it is common to store data in different formats like VARCHAR, INT, FLOAT, etc. based on the needs of the application. However, sometimes we may need to convert a VARCHAR column to an INT for performing arithmetic operations, comparisons or other logical queries that require integer values. This article will explore various ways to convert VARCHAR (string) data types to INT in SQL using the built-in functions the potential pitfalls and examples. Why Convert VARCHAR to INT? While working with databases we may need to convert VARCHAR to INT in the following scenarios − ...

Read More

How To Reset Identity Column Values In SQL

SQL
Samriddhi Sharma
Samriddhi Sharma
Updated on 11-Oct-2024 177 Views

What is an Identity Column? The Identity column of a table is a column whose value increments consequently. This can be used to create unique identifiers, such as primary keys. Syntax Following is the syntax to create an Identity column. The initial setting for identity is represented as IDENTITY (1, 1). IDENTITY [ ( seed , increment ) ] Where − Seed: The seed determines the initial value of an ID, with a default setting of 1. Increment: This denotes the step value for ID increments, which also defaults ...

Read More

How to Set a Column Value to Null in SQL?

SQL
Samriddhi Sharma
Samriddhi Sharma
Updated on 11-Oct-2024 568 Views

Setting a Column Value to Null To set a column value to NULL, use the SQL UPDATE statement, which allows modification of existing records in a table. The basic syntax for setting a column value to NULL is − Syntax UPDATE table_name SET column_name = NULL WHERE conditions; Where − table_name: Replace this with the name of the table you intend to update. column_name: Substitute this with the name of the column to be updated. NULL: Denotes the NULL value in SQL. ...

Read More

Data Architecture Design & Data Management

Amrendra Patel
Amrendra Patel
Updated on 11-Oct-2024 3K+ Views

Data architecture design consists of standards that have certain rules, policies, and data types to be collected, from where the data is collected, storage of data, arrangement of data, and then using that data for further analysis. Data plays a vital role in the successful execution of business strategy. Data architecture design It helps us to show how users view the data in the database. It describes the type of data structures used to manage data and make the processing easy. the concept of dbms depends on its architecture. It is divided into three models i.e. conceptual model, ...

Read More

How to print duplicate rows in a table SQL

SQL
Akshada Bornare
Akshada Bornare
Updated on 25-Sep-2024 261 Views

Assume we have created a table in database and the table consists of duplicate records or, you need to check if there are multiple entries of the same record in the database. In order to find such duplicate records you can make use of below sample queries. Printing Duplicate Rows in an SQL Table Lets consider we have a table named as Students with the columns ID, Name, Age. Using the following query − CREATE TABLE Students( ID INT NOT NULL, NAME VARCHAR (20) NOT NULL, AGE ...

Read More
Showing 21–30 of 114 articles
« Prev 1 2 3 4 5 12 Next »
Advertisements