How to check if value already exists in mysql database in php?



How to check if value already exists in mysql database in php?..

Answer / Ark Gopal

To check if a value already exists in a MySQL database using PHP, you can use a SELECT statement with the COUNT() function and the LIMIT clause. Here's an example:nn```phpn$sql = "SELECT COUNT(*) FROM table_name WHERE column_name = 'value'";n$result = mysqli_query($conn, $sql);n$row = mysqli_fetch_array($result);nif ($row[0] > 0) {n // value existsn}n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More MySQL Interview Questions

What is blob datatype in mysql?

1 Answers  


Explain GRANT command in MySQL.

1 Answers  


What are the steps required to view your mysql database?

1 Answers  


How does limit work in mysql?

1 Answers  


How do I edit a table in mysql?

1 Answers  


What is mysqlcommand?

1 Answers  


Table - Products has number of products as below Productid ProductName 1 iPhone 2 iPad 3 BlackBerry Table - SalesPersonProduct has the below records Salespersonid productid S1 1 S1 2 S1 3 S2 1 S3 2 Write a SQL query that returns the total number of sold products

1 Answers  


Write a query to stop mysql in unix

1 Answers  


How are mysql timestamps seen to a user?

1 Answers  


What is longblob in mysql?

1 Answers  


How can you make a database as your current database?

1 Answers  


Consider you have the following three tables which have to be linked together.

1 Answers  


Categories