Create Table Query with Manual Auto Increment Start Value in MySQL

AmitDiwan
Updated on 30-Dec-2019 06:24:21

186 Views

Let us first create a table −mysql> create table DemoTable1907    (    UserId int NOT NULL AUTO_INCREMENT,    UserName varchar(20),    UserAge int,    UserCountryName varchar(20),    PRIMARY KEY(UserId)    )ENGINE=MyISAM, AUTO_INCREMENT=100; Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1907(UserName, UserAge, UserCountryName) values('Chris', 26, 'US'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1907(UserName, UserAge, UserCountryName) values('David', 38, 'UK'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1907(UserName, UserAge, UserCountryName) values('John', 28, 'AUS'); Query OK, 1 row affected (0.00 sec)Display all records from the ... Read More

Change Format of Dates in MySQL Table Column

AmitDiwan
Updated on 30-Dec-2019 06:22:02

486 Views

To change format of dates, use the DATE_FORMAT() function. Let us first create a table −mysql> create table DemoTable1906    (    DueTime datetime    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1906 values(now()); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1906 values(curdate()); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1906 values('2017-10-11'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1906 values('2015-01-12'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1906 values('2018-04-25'); Query OK, 1 row affected (0.00 ... Read More

Fasten MySQL Count Distinct Values Process

AmitDiwan
Updated on 30-Dec-2019 06:20:28

405 Views

To fasten the process, you can use INDEX. Let us first create a table −mysql> create table DemoTable1905    (    FirstName varchar(20),    LastName varchar(20) ,    INDEX F_L_Name(FirstName, LastName)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1905 values('John', 'Smith'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1905 values('John', 'Doe'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1905 values('Adam', 'Smith'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1905 values('John', 'Doe'); Query OK, 1 row affected (0.00 sec) ... Read More

Escape Backslashes in MySQL with JDBC

AmitDiwan
Updated on 30-Dec-2019 06:17:55

420 Views

To escape backslashes, use PreparedStatement while inserting records. Let us first create a table −mysql> create table DemoTable1904    (    ClientId int,    ClientName varchar(20),    ClientAge int    ); Query OK, 0 rows affected (0.00 sec)The Java code is as follows −import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; public class EscapeBackslashesDemo {    public static void main(String[] args) {       Connection con = null;       PreparedStatement ps = null;       try {          con = DriverManager.getConnection("jdbc:mysql://localhost:3306/web?" + "useSSL=false", "root", "123456");          String query = "insert into DemoTable1904(ClientId, ... Read More

MySQL Update Column Names and Set None Values with N/A

AmitDiwan
Updated on 30-Dec-2019 06:14:54

306 Views

Let us first create a table −mysql> create table DemoTable1903    (    FirstName varchar(20),    LastName varchar(20) ,    Age int    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1903 values('John', 'Smith', 23); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1903 values('None', 'Miller', 28); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1903 values('None', 'Taylor', 26); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1903 values('Chris', 'Brown', 26); Query OK, 1 row affected (0.00 sec)Display all records from the table ... Read More

Filter Input Function in PHP

Ankith Reddy
Updated on 27-Dec-2019 10:24:27

657 Views

The filter_input() function gets a name of external variable and filters it optionally.Syntaxfilter_input(type, var, filtername, options)Parameterstype − There are five types of inputs to check i.e. INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, or INPUT_ENV.var − The name of variable.filtername − The name of filter to get ID.options − Specifies options to use.ReturnThe filter_input() function returns the value of the variable on success, false on failure, or null if the parameter of variable is not set.Example Live Demo

Filter ID Function in PHP

Arjun Thakur
Updated on 27-Dec-2019 10:23:35

335 Views

The filter_id() function returns the filter ID of provided filter name.Syntaxfilter_id(filtername)Parametersfiltername − The name of filter to get the ID from.ReturnThe filter_id() function returns filter ID on success or FALSE, if the filter does not exist.ExampleOutputThe following is the output.int = 257 boolean = 258 float = 259 validate_regexp = 272 validate_domain = 277 validate_url = 273 validate_email = 274 validate_ip = 275 validate_mac = 276 string = 513 stripped = 513 encoded = 514 special_chars = 515 full_special_chars = 522 unsafe_raw = 516 email = 517 url = 518number_int = 519 number_float = 520 magic_quotes = 521 callback = 1024

Filter Has Var Function in PHP

Ankith Reddy
Updated on 27-Dec-2019 10:22:28

415 Views

The filter_has_var() function is used to check that variable of specified type exists or not.Syntaxfilter_has_var(type, var)Parameterstype − There are five types of inputs to check i.e. INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, or INPUT_ENV.var − The name of variable.ReturnThe filter_has_var() function returns true on success and false on failure.ExampleThe following is an example that is a quick check for the input variable "email”. The value INPUT_GET is used for this. Live Demo

Filter and Validate Float Constant in PHP

Ankith Reddy
Updated on 27-Dec-2019 10:21:28

342 Views

The FILTER_VALIDATE_FLOAT constant validates a value as a float number.ReturnThe FILTER_VALIDATE_FLOAT constant does not return anything.Example Live DemoOutputThe following is the output.float(291.9)

Filter and Validate Email Constant in PHP

George John
Updated on 27-Dec-2019 10:17:35

458 Views

The FILTER_VALIDATE_EMAIL() constant validates an email address.ReturnThe FILTER_VALIDATE_EMAIL() does not return anything.Example Live DemoOutputThe following is the output.examplee@demo.com = valid email address

Advertisements