AmitDiwan has Published 11365 Articles

How do I use the @ sign in MySQL?

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 06:51:43

333 Views

To use the @ sign, use MySQL SET command. The @sign is used to set user-defined variables. Following is the syntax −SET @anyVariableName:=yourValue;Let us first create a table −mysql> create table DemoTable1331    -> (    -> Id int,    -> Name varchar(20)    -> ); Query OK, 0 rows ... Read More

How do I format a number as decimal to store it in MySQL?

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 06:48:12

143 Views

You do not need to format a number in MySQL, for this use DECIMAL data type. Let us first create a table −mysql> create table DemoTable1330    -> (    -> Amount DECIMAL(10, 2)    -> ); Query OK, 0 rows affected (0.85 sec)Insert some records in the table using ... Read More

CharEnumerator.GetType() Method in C#

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 06:47:59

22 Views

The CharEnumerator.GetType() method in C# is used to get the type of the current instance.Syntaxpublic Type GetType();Let us now see an example to implement the CharEnumerator.GetType() method −Exampleusing System; public class Demo {    public static void Main(){       string strNum = "john";       CharEnumerator ch ... Read More

How to TRIM x number of characters, beginning from the last in MySQL?

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 06:45:55

200 Views

For this, you can use substring() along with length(). Let us first create a table −mysql> create table DemoTable1329    -> (    -> StudentName varchar(40)    -> ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1329 values('David Miller'); ... Read More

Insert values in a table by MySQL SELECT from another table in MySQL?

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 06:41:53

785 Views

Fir this, use INSERT INTO SELECT statement. Let us first create a table −mysql> create table DemoTable1    -> (    -> Id int,    -> Name varchar(20),    -> Age int    -> ); Query OK, 0 rows affected (1.72 sec)Insert some records in the table using insert command ... Read More

MySQL query to extract time in a format without seconds

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 06:38:25

298 Views

For this, you can use time_format(). Let us first create a table −mysql> create table DemoTable1326    -> (    -> Arrivaltime time    -> ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1326 values('12:10:45'); Query OK, 1 row ... Read More

Order MySQL results without identifier?

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 06:35:51

93 Views

To order MySQL results without identifier, the syntax is as follows −select * from yourTableName order by 1 DESC LIMIT yourLimitValue;Let us first create a table −mysql> create table DemoTable1325    -> (    -> Id int,    -> Name varchar(20)    -> ); Query OK, 0 rows affected (0.69 ... Read More

How to identify composite primary key in any MySQL database table?

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 06:28:38

1K+ Views

You can use aggregate function count(*). If it returns a value greater than 1, that would mean the table has composite primary key.Let us first create a table −mysql> create table DemoTable1324    -> (    -> StudentId int,    -> StudentName varchar(20),    -> StudentAge int,    -> StudentCountryName ... Read More

MySQL query to get the last created table name (most recent)?

AmitDiwan

AmitDiwan

Updated on 05-Nov-2019 06:26:19

188 Views

You can use the concept INFORMATION_SCHEMA.TABLES for this. Let us first create a table. This would be our most recent table −mysql> create table DemoTable1323    -> (    -> FirstName varchar(10)    -> ); Query OK, 0 rows affected (0.43 sec)Insert some records in the table using insert command ... Read More

Create a MySQL table from already created table selecting specific rows?

AmitDiwan

AmitDiwan

Updated on 04-Nov-2019 11:11:01

97 Views

To create a table from an already created table, use CREATE TABLE AS SELECT statement. Let us first create a table −mysql> create table DemoTable1318 -> ( -> Id int, -> FirstName varchar(10), -> LastName varchar(10), -> Age int -> ); Query OK, 0 rows affected (0.50 sec)Insert some records ... Read More

Advertisements