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 affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1331 values(10, 'Chris'); Query OK, 1 row affected (0.71 sec) mysql> insert into DemoTable1331 values(101, 'David'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1331 values(40, 'Bob'); Query OK, 1 row affected (0.12 sec) ... Read More
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 insert command −mysql> insert into DemoTable1330 values(10944.7893); Query OK, 1 row affected, 1 warning (0.13 sec) mysql> insert into DemoTable1330 values(9848.44); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1330 values(8009.90); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1330 values(1000.99); Query OK, 1 row affected ... Read More
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 = strNum.GetEnumerator(); Console.WriteLine("HashCode = "+ch.GetHashCode()); Console.WriteLine("Get the Type = "+ch.GetType()); while (ch.MoveNext()) Console.Write(ch.Current + " "); // disposed ch.Dispose(); // this will show an error since we disposed ... Read More
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'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1329 values('Chris Brown'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1329 values('Adam Smith'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable1329 values('John Doe'); Query OK, 1 row affected (0.44 sec)Display all records from the ... Read More
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 −mysql> insert into DemoTable1 values(100, 'Chris', 24); Query OK, 1 row affected (0.61 sec) mysql> insert into DemoTable1 values(101, 'Adam', 23); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1 values(102, 'John', 25); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1 values(103, 'Carol', 26); Query ... Read More
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 affected (0.14 sec) mysql> insert into DemoTable1326 values('20:00:00'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1326 values('22:45:55'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1326 values('04:10:24'); Query OK, 1 row affected (0.11 sec)Display all records from the table using select statement −mysql> select * ... Read More
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 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1325 values(100, 'Chris'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1325 values(101, 'Bob'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1325 values(120, 'David'); Query OK, 1 row affected (0.14 sec) mysql> insert ... Read More
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 varchar(20) -> ); Query OK, 0 rows affected (0.52 sec)Here is the query to add composite primary key −mysql> alter table DemoTable1324 ADD CONSTRAINT constr_IdAgeCountry PRIMARY KEY (StudentId, StudentAge, StudentCountryName); Query OK, 0 rows affected (1.29 sec) Records: 0 Duplicates: 0 Warnings: 0Following is the query to identify composite ... Read More
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 −mysql> insert into DemoTable1323 values('Chris'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1323 values('David'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1323 values('Bob'); Query OK, 1 row affected (0.11 sec)Display all records from the table using select statement −mysql> select *from DemoTable1323;This will produce ... Read More
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 in the table using insert command −mysql> insert into DemoTable1318 values(1, 'Chris', 'Brown', 21); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1318 values(2, 'David', 'Miller', 24); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1318 values(3, 'Carol', 'Taylor', 23); Query OK, 1 row affected (0.11 ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP