Jump to content

Why doees this SQL insert 0 rows?


rain13

Recommended Posts

Hello.

 

 

I am stuck with sql. I want to insert row if it does not exist. This sql worked on localhost but does not work on other server. Any ideas?

INSERT INTO hashtags SELECT DISTINCT 'test','2','1' FROM hashtags WHERE NOT EXISTS (SELECT * FROM hashtags  WHERE  Tag='test' AND ForumID = '2')
Link to comment
Share on other sites

I'm showing you how to debug your query. mysqli_num_rows() simple lets you check the part of your query that doing the selection. Obviously, no selection means no insert.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...