Check if a record exist return an incorrect result

mysql check if row exists before insert
sql check if record exists
how to return true or false in sql stored procedure
if exists mysql w3schools
return true if record exists sql
sql check if value already exists
how to check if record already exist in sql
sql check if record exists in another table

I have a table called match_lineup_substitute which have the following record:

player_substitute_id | player_substituted_id | match_id |
       90930                   NULL             2807486

I want check if the record exist, so I wrote this query:

SELECT COUNT(*) FROM `match_lineup_substitute` 
                WHERE match_id = 2807486 AND 
                player_substitute_id = 90930 AND player_substituted_id = null         

this will return: 0

what happened?

Change from

player_substituted_id = null 


player_substituted_id IS NULL 

If you want to check null value in field you have to use IS NULL in where clause.

How to find out if a record already exists in a database, If it doesn't , How do you check if record already exists in SQL? How can I check to see if a Record exists for this particular response, if not then create a new record. I was thinking of testing by using the lookup function, to see if a record existed that had the Question ID and User().Email, as the combination of these would be unique for each record.

To check for null values use is

... and player_substituted_id IS NULL


Best way to test if a row exists in a MySQL table, How do you check if a row exists in SQL? If you are only checking that the record exists then you can try to use select 1 instead of select * Also the syntax is presently wrong, it should be select * from table1(you are missing the from) – Rahul Tripathi Jan 29 '16 at 11:45

NULL is not a value (see it as "value is unknown"), therefore column = NULL always returns NULL.

NULL AND something returns NULL

So your WHERE condition doesn't return TRUE (since it returns NULL), so the row is not selected.

Use column IS NULL instead.

Note that the same is true if you compare two columns : column1 = column2will be NULL for each row where column1 or column2 is NULL.


Return Boolean Value on SQL Select Statement, The value will be returned as 1 (True) if record exists and 0 (False) is record of assigning result value EXEC function to Variable in SQL Server, the following  DECLARE @CustId INT = 2 IF EXISTS(SELECT 1 FROM dbo.Customer WITH(NOLOCK) WHERE CustId = @CustId) BEGIN PRINT 'Record Exists' END ELSE BEGIN PRINT 'Record doesn''t Exists' END RESULT: [ALSO READ] How to check if a Table exists

In MySQL you should use IS NULL (or IS NOT NULL) to evaluate if a value is (or isn't) null, instead of using arithmetic comparison operators.

In your example, you should replace

AND player_substituted_id = null


... AND player_substituted_id IS NULL 

You can read more about it in the Working with NULL values section of the official documentation.


To test for NULL, use the IS NULL and IS NOT NULL operators (...)


You cannot use arithmetic comparison operators such as =, <, or <> to test for NULL.

Stored Procedure: Return True if record exists and False if record , if ($EntryExistsBoolean === false) { echo "Item does not exist in the the result $​row = sqlite_fetch_row($qResult); // Check if a row is returned  LookUp will return a blank item if it doesn't find any matches, so IsBlank will return true if the user is not found, and since you want the opposite of it for the visibility (button visible if the user is found) then you can use Not to invert that result.

Return boolean if item EXISTS in database, This is useful for those cases where you do not know the type of the operands being compared. This is useful to diagnose what went wrong. If your script It returns the RecNo of the object referenced if the record does exist, or 0 otherwise​. When you add a record to a Recordset, you might expect that record to become the current record. If that's your expectation, your code will fail to return the expected results because that is not

Match-IT Product Manual, Figure 23-6 shows the correct method for writing a check for an amount less than a If the stub is not completed and the check is sent out, no record exists of the taken from the account until the cancelled check is returned at a later date. Here Mudassar Ahmed Khan has explained with an example, how to return value True if record exists and value False when record does not exist from Stored Procedure in SQL Server. In order to return value the EXEC function will be used. The value will be returned as 1 (True) if record exists and 0 (False) is record does not exists. Using the EXEC function returning value of a Stored Procedure to

Kinn's The Administrative Medical Assistant, To test whether a row exists in a MySQL table or not, use exists condition. The exists condition It returns true when row exists in the table, otherwise false is returned. True is I am applying the above query to get the result − Here’s a little trick you can use to return TRUE/FALSE if a query has returned results. For example if a Person is in Category_ID 325 or 326 we want TRUE, otherwise FALSE. This trick uses the COUNT functionto check for any returned rows then a CASE statement and CAST to return either TRUE or FALSE.

  • To check for null values, we use IS NULL not = null
  • I'd avoid such similar column names. player_substitute_id and player_substituted_id will cause trouble.
  • Possible duplicate of:
  • NULL = NULL yields NULL which isn't TRUE. NULL IS NULL yields TRUE , which is useful to you. Most operations on NULL yield NULL and need very specific care in handling them.