Sharon Christine has Published 446 Articles

How to search a MySQL table for a specific string?

Sharon Christine

Sharon Christine

Updated on 30-Jun-2020 14:31:36

1K+ Views

Use equal to operator for an exact match −select *from yourTableName where yourColumnName=yourValue;Let us first create a table −mysql> create table DemoTable -> ( -> FirstName varchar(100), -> LastName varchar(100) -> ); Query OK, 0 rows affected (0.70 secInsert some records in the table using insert command −mysql> insert into ... Read More

How to update multiple rows and left pad values in MySQL?

Sharon Christine

Sharon Christine

Updated on 30-Jun-2020 14:29:56

298 Views

Use the LPAD() function to left pad values. Let us first create a table −mysql> create table DemoTable    -> (    -> Number int    -> ); Query OK, 0 rows affected (2.26 secInsert some records in the table using insert command −mysql> insert into DemoTable values(857786); Query OK, ... Read More

Find and display duplicate values only once from a column in MySQL

Sharon Christine

Sharon Christine

Updated on 30-Jun-2020 14:21:28

567 Views

Let us first create a table −mysql> create table DemoTable -> ( -> value int -> ); Query OK, 0 rows affected (0.82 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(100); ... Read More

If I truncate a table, should I also add indexes?

Sharon Christine

Sharon Christine

Updated on 30-Jun-2020 14:19:51

597 Views

If you truncate a table, you do not need to add indexes because table is recreated after truncating a table and indexes get added automatically.Let us first create a table −mysql> create table DemoTable    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> FirstName varchar(20), ... Read More

MySQL query to return a substring after delimiter?

Sharon Christine

Sharon Christine

Updated on 30-Jun-2020 14:18:32

632 Views

Use SUBSTRING() to return values after delimiter. Let us first create a table −mysql> create table DemoTable -> ( -> Title text -> ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John is good in MySQL, Sam is ... Read More

Selecting data from a MySQL table based on a specific month?

Sharon Christine

Sharon Christine

Updated on 30-Jun-2020 14:14:30

171 Views

Use the MONTH() method in MySQL to select date based on month. Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserName varchar(10), -> UserPostMessageDate datetime, -> UserLikes int -> ); Query OK, 0 rows affected (0.77 sec)Insert ... Read More

Can we combine MySQL IN AND LIKE operators?

Sharon Christine

Sharon Christine

Updated on 30-Jun-2020 14:12:18

519 Views

Yes, we can combine IN and LIKE operators in MySQL using LIKE and OR operator. Let us first create a table −mysql> create table DemoTable -> ( -> SubjectTitle text -> ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into ... Read More

Adding integers from a variable to a MySQL column?

Sharon Christine

Sharon Christine

Updated on 30-Jun-2020 14:06:34

578 Views

To set a variable, use MySQL SET. For adding integers from a variable, use UPDATE and SET as in the below syntax −set @anyVariableName:=yourValue; update yourTableName set yourColumnName=yourColumnName+ @yourVariableName;Let us first create a table −mysql> create table DemoTable -> ( -> Number int -> ); Query OK, 0 rows affected ... Read More

Is it impossible to add a column in MySQL specifically before another column?

Sharon Christine

Sharon Christine

Updated on 30-Jun-2020 14:05:36

266 Views

No, you can easily add a column before another column using ALTER.Note − To add a column at a specific position within a table row, use FIRST or AFTER col_name Let us first create a table −mysql> create table DemoTable    -> (    -> Id int,    -> Name ... Read More

MySQL XOR operator with IN clause?

Sharon Christine

Sharon Christine

Updated on 30-Jun-2020 14:03:58

521 Views

MySQL XOR returns TRUE if one or the other operand (or expression) but not both is TRUE. The IN clause is used to specify a condition with any other MySQL query.Let us first create a tablemysql> create table DemoTable -> ( -> Num1 int, -> Num2 int -> ); Query ... Read More

Previous 1 ... 4 5 6 7 8 ... 45 Next
Advertisements