MySQL Query to Select Everything to Left of Last Space in a Column

AmitDiwan
Updated on 30-Dec-2019 07:58:21

304 Views

For this, you can use LEFT(). Let us first create a table −mysql> create table DemoTable1939    (    FullName varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1939 values('Adam Smith'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1939 values('Robert Downey, Jr.'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1939 values('Sylvester Stallone'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1939 values('Chris Hemsworth'); Query OK, 1 row affected (0.00 sec)Display all records from the table using select statement −mysql> ... Read More

intlchar_isjavaidstart Function in PHP

karthikeya Boyini
Updated on 30-Dec-2019 07:57:50

62 Views

The IntlChar::isJavaIDStart() function is used to check whether the entered character is permissible since the first character is a java identifier or not.SyntaxIntlChar::isJavaIDStart(val)Parametersval − A character or integer value encoded as a UTF-8 string.ReturnThe IntlChar::isJavaIDStart() function returns TRUE if the val begins withJava identifier character.ExampleThe following is an example −OutputThe following is the output −bool(true) bool(true)ExampleLet us see another example −OutputThe following is the output −NULL bool(true) NULL NULL

Display All Fields of a Table in MySQL

AmitDiwan
Updated on 30-Dec-2019 07:56:20

1K+ Views

To display all fields, set the database with table_schema and specific table with table_name as in the below syntax −select column_name as anyAliasName from information_schema.columns    where table_schema=database()    and table_name=’yourTableName’\GLet us first create a table −mysql> create table DemoTable1938    (    StudentId int,    StudentName varchar(20),    StudentAge int,    StudentCountryName varchar(20),    StudentMobileNumber bigint    ); Query OK, 0 rows affected (0.00 sec)Here is the query to display all fields of a table −mysql> select column_name as ALL_FIELDS from information_schema.columns    where table_schema=database()    and table_name='DemoTable1938'\GThis will produce the following output −*************************** 1. row *************************** ALL_FIELDS: StudentId ... Read More

MySQL Order By ASC and Display NULLs at the Bottom

AmitDiwan
Updated on 30-Dec-2019 07:54:41

584 Views

For this, use CASE statement with ORDER BY. Let us first create a table −mysql> create table DemoTable1937    (    Name varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1937 values('Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1937 values(NULL); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1937 values('Adam'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1937 values('John'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1937 values(''); Query OK, 1 row affected (0.00 sec) ... Read More

Perform Multiple Inserts with INSERT INTO SELECT and UNION in MySQL

AmitDiwan
Updated on 30-Dec-2019 07:51:53

3K+ Views

To perform multiple inserts, the syntax is as follows −insert into yourTableName(yourColumnName1, yourColumnName2, yourColumnName3, ..N)    select yourValue1 as yourColumnName1, yourValue2 as yourColumnName2, yourValue3 as yourColumnName3, ......N    union    select yourValue1 as yourColumnName1, yourValue2 as yourColumnName2, yourValue3 as yourColumnName3, ......N . . NTo understand the above syntax, let us create a table −mysql> create table DemoTable1936    (    StudentId int,    StudentName varchar(20),    StudentCountryName varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1936(StudentId, StudentName, StudentCountryName)    select 1001 as StudentId, 'Chris' as StudentName, 'US' ... Read More

intlchar_isbase Function in PHP

karthikeya Boyini
Updated on 30-Dec-2019 07:50:46

119 Views

The IntlChar::isbase() function is used to check the given input data is a base character or not.SyntaxIntlChar::isbase( val)Parametersval − An integer or character encoded as a UTF-8 string. Required.ReturnThe IntlChar::isbase() function returns TRUE if the val is a base character.ExampleThe following is an example −OutputThe following is the output −bool(true) NULL NULL NULL

Check If a String Ends with Given Word in PHP

Samual Sam
Updated on 30-Dec-2019 07:50:17

546 Views

Create a function to check whether a string ends with the specified string or not. The function should return TRUE on success or FALSE on failure.The following is the syntax −endFunc(str, lastStr)Consider the following parameters in it to check −str − The string to be testedlastStr − The text to be searched in the end of the specified string.ExampleThe following is an example − Live DemoOutputThe following is the output −False!

intlchar_isalpha Function in PHP

karthikeya Boyini
Updated on 30-Dec-2019 07:49:49

383 Views

The IntlChar::isalpha() function is used to check the given input is an alphanumeric character or not.SyntaxIntlChar::isalpha( $val )Parametersval − An integer values or character encoded as a UTF-8 string.Required.ReturnThe IntlChar::isalpha() function returns TRUE if the val is alphanumeric character.ExampleThe following is an example −OutputThe following is the output −bool(false) bool(true)ExampleLet us see another example wherein we are checking for alphanumeric characters −OutputThe following is the output −NULL NULL NULL bool(true)

intlchar_isUppercase Function in PHP

Samual Sam
Updated on 30-Dec-2019 07:49:14

126 Views

The IntlChar::isUUppercase() function checks whether the given input character is an Uppercase Unicode character or not.SyntaxIntlChar::isUUppercase(val)Parametersval − It is a character value, which is encoded as a UTF-8 string.ReturnThe IntlChar::isUUppercase() function returns TRUE if the val is an Uppercase Unicode character or not.ExampleThe following is an example −OutputThe following is the output −bool(false) NULL bool(true)ExampleLet us see another example −OutputThe following is the output −bool(false) bool(false) bool(true)

MySQL Query to Display Records Using LIKE with Multiple Words

AmitDiwan
Updated on 30-Dec-2019 07:49:12

345 Views

For this, use RLIKE and filter records as in the below syntax &Minus;select * from yourTableName    where yourColumnName rlike 'yourValue1|yourValue2';Let us first create a table −mysql> create table DemoTable1935    (    Subject varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1935 values('MySQL'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1935 values('Python'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1935 values('MongoDB'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1935 values('SQL Server'); Query OK, 1 row affected (0.00 ... Read More

Advertisements