pleaseeeeeeee hepl meeeeeeee!!!!!!!!!

i have 2 tables :
time1 (noo integer,days varchar,times varchar,Tindex integer,primary key
(noo,Tindex))

timetable1_1(COn integer,coursename varchar,dayss varchar,timess varchar,
primary key(COn))


i have created a new table temptime1 and tried to fill it with the rows in time1 which their days and times are not available in timetable1_1

i used the below query but it gives me error: "Operand should contain 1 column"


QUERY:

insert into TempTime1 (NOM,Tday,Ttime,Ttindex) select * from time1 where days and times not in (select * from timetable1_1)

Recommended Answers

All 3 Replies

INSERT INTO TempTime1 (NOM,Tday,Ttime,Ttindex) SELECT * FROM time1 WHERE days AND times NOT IN (SELECT * FROM timetable1_1) Few things to note here

you are inserting values into 4 columns of TempTime1 table with
select * from time1
where time1 has more than 4 columns,so that's a error

and the second one : SELECT * FROM time1 WHERE days AND times NOT IN (SELECT * FROM timetable1_1) you can't put 2 columns "days AND times" and say not in.......
and then you are trying to GET times which are not in timetable1_1
you have specify
select times from timetable1_1 as the inner query is returning more than 1 column


try this

INSERT INTO TEMPTIME1
SELECT TOTAL.DAYS,TOTAL.TIMES,TOTAL.TINDEX FROM
(SELECT TIME1.DAYS,TIME1.TIMES,TIME1.TINDEX FROM
 TIME1
 LEFT OUTER JOIN TIMETABLE1_1
      ON TIME1.TIMES=TIMETABLE1_1.TIMES
       AND TIME1.DAYS=TIMETABLE1_1.DAYS
 HAVING (TIMETABLE1_1.TIMES IS NULL AND TIMETABLE1_1.DAYS IS NULL)
)TOTAL

yeah you are right . i was in a big mistake.
so i used the below query and it worked:

insert into TempTime1(Tday,Ttime) select days,times from time1  where days not in (select dayss1 from timetable1_1 ) union select days,times from time1  where times not in (select timess1 from timetable1_1 )

It's really simple...
all you have to do is replace inner * with your desired columns

The correct QUERY would be:

insert into TempTime1 (NOM,Tday,Ttime,Ttindex) select * from time1 where days and times not in (select days, times from timetable1_1)

QUERY:

insert into TempTime1 (NOM,Tday,Ttime,Ttindex) select * from time1 where days and times not in (select * from timetable1_1)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.