SELECT DATABASE() - Show the default database USE databaseName - Set the default (current) database SHOW DATABASES - Show all the databases in this server Database-LevelĭROP DATABASE databaseName - Delete the database (irrecoverable!)ĭROP DATABASE IF EXISTS databaseName - Delete if it existsĬREATE DATABASE databaseName - Create a new databaseĬREATE DATABASE IF NOT EXISTS databaseName - Create only if it does not exists Summary of MySQL Commands Used in this Tutorialįor detailed syntax, check MySQL manual "SQL Statement Syntax". You can view EDUCBA’s recommended articles for more information.Read " How to Install MySQL and Get Started" on how to install, customize, and get started with MySQL. We hope that this EDUCBA information on “MySQL not equal” was beneficial to you. The ‘Not Equal’ operator is used to specify an expression, and only the rows that satisfy the expression will be displayed, while the rest will be omitted. We use the mentioned symbols to utilize the operations of operators. MySQL Not Equal filters the rows that are ‘NOT Equal to’ the specified ‘value’. WHERE SERIAL_NO IN( SELECT SERIAL_NO FROM TEST_NOT_EQUAL WHERE LOCATION !='USA') WHERE SERIAL_NO IN( SELECT SERIAL_NO FROM TEST_NOT_EQUAL WHERE LOCATION 'USA') We have used the “IN” operator to retrieve the data “equal to” the inner output. It is here based on the output of the inner query. SELECT SERIAL_NO FROM TEST_NOT_EQUAL WHERE LOCATION 'USA' The output of the inner query is below, which will get the data from the table where the location is not equal to ‘USA’. WHERE SERIAL_NO IN ( SELECT SERIAL_NO FROM TEST_NOT_EQUAL WHERE We can perform the Sub query for the same table and apply the ‘not equal’. You can see that the output has filtered the ‘USA’ data and returned the rest in the above out. SELECT * FROM TEST_NOT_EQUAL WHERE LOCATION 'USA' Now let us get the data from the table where Location is not equal to ‘USA’. Now let us see the data from the table: – Select * from test_not_equal INSERT INTO TEST_NOT_EQUAL VALUES (6, 'Rodger', 'Norway', 24, 'Software Engineer', '7893412564' ) INSERT INTO TEST_NOT_EQUAL VALUES (3, 'Will', 'Denmark', 24, 'Software Engineer', '7656789843' ) Insert data into the table: – INSERT INTO TEST_NOT_EQUAL VALUES (1, 'Rose', 'USA', 24, 'Software Engineer', '9876545676' ) Now let us consider another table below and find the working of ‘Not Equal’. Where id NOT IN( select id from job_status where status != 'yes') This means we get the output as id = 1, 2, 5, 6. This output will be passed to the outer query, which gets the id row data not equal to 3,4. Here the output from the inner query is 3,4. Select id from job_status where status != 'yes' Here let us see the output of the inner query first. Where id not in( select id from job_status where status != 'yes') Using not equal in a subquery: – Select * from not_equal_demo SELECT * FROM NOT_EQUAL_DEMO WHERE AMOUNT != 35000 īoth the symbols act similarly and get the data from the table. Here in the above query, we filter the data and extract all rows that are not equal to 35000. SELECT * FROM NOT_EQUAL_DEMO WHERE AMOUNT 35000 But, first, let us get the data from the table where the amount is not equal to 35000. Now let us filter the data from the above table. Now let us select data from the above table: – Select * from job_status Insert into job_status values ( 6, 'yes') Insert into job_status values ( 5, 'yes') Insert into job_status values ( 4, 'no') Insert into job_status values ( 3, 'no') Insert into job_status values ( 2, 'yes') Insert data into the table as below: – insert into job_status values ( 1, 'yes') Let us select the data from the above table: – Select * from Not_equal_demo Ĭonsider another table as below: – create table job_status Insert into Not_equal_demo values ( 6, 'Robert', 35000 ) Insert into Not_equal_demo values ( 5, 'Pinky', 35000 ) Insert into Not_equal_demo values ( 4, 'Henry', 56000 ) Insert into Not_equal_demo values ( 3, 'Will', 79000 ) Insert into Not_equal_demo values ( 2, 'Sam', 89000 ) Insert the below rows into the above table: – insert into Not_equal_demo values ( 1, 'Rose', 90000 ) Now let us create a table, apply the ‘not equal’ operator, and check how it works. != 'value' How does MySQL Not Equal work?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |