1
CREATE TABLE IF NOT EXISTS Orari (ID int AUTO_INCREMENT PRIMARY KEY,titolo Char(40), sala int ,giorno char(10),Ora char(10));

INSERT INTO Orari VALUES (null,null,1,'lunedi','16:30'),
    (null,null,1,'lunedi','19:30'),
    (null,null,2,'lunedi','16:30'),
    (null,null,2,'lunedi','19:30'),
    (null,null,1,'martedi','16:30'),
    (null,null,1,'martedi','19:30'),
    (null,null,2,'martedi','16:30'),
    (null,null,2,'martedi','19:30'),
    (null,null,1,'mercoledi','16:30'),
    (null,null,1,'mercoledi','19:30'),
    (null,null,2,'mercoledi','16:30'),
    (null,null,2,'mercoledi','19:30'),
    (null,null,1,'giovedi','16:30'),
    (null,null,1,'giovedi','19:30'),
    (null,null,2,'giovedi','16:30'),
    (null,null,2,'giovedi','19:30'),
    (null,null,1,'venerdi','16:30'),
    (null,null,1,'venerdi','19:30'),
    (null,null,2,'venerdi','16:30'),
    (null,null,2,'venerdi','19:30'),
    (null,null,1,'sabato','16:30'),
    (null,null,1,'sabato','19:30'),
    (null,null,2,'sabato','16:30'),
    (null,null,2,'sabato','19:30'),
    (null,null,1,'domenica','16:30'),
    (null,null,1,'domenica','19:30'),
    (null,null,2,'domenica','16:30'),
    (null,null,2,'domenica','19:30');

I want to put it in a function which im going to call every time i press a Button.

The IF NOT EXISTS work for the first query ... and if the table already exists it does'nt recreate it.

But the second query for inserting Values just keeps inserting again and again every time I push the button.

Is there any comand like IF NOT EXISTS for Inserting values?

Mark Rotteveel
  • 82,132
  • 136
  • 114
  • 158
Haider Ali
  • 27
  • 1

1 Answers1

0

Try NOT EXISTS or EXISTS in where clause

Rakesh
  • 607
  • 2
  • 10
  • 29