Hi I'm trying to insert a row using the following query and immediately retrieve the primary key with a select query as shown below:
insert query:
INSERT INTO service_user( Sexuality_ID, First_Name, Last_Name, Gender_ID, Address1, Address2, Postcode, Telephone, Mobile_Phone, Faith_ID, Ethnicity_ID, Nationality, Disability, HeardAboutService, DOB, PrContact, Creating_Staff )
VALUES ( 1, 'test', NULL , 1, 'qqq', 'jjjj', NULL , NULL , NULL , 1, 1, NULL , NULL , NULL , '2000-02-12', NULL , 1 )
select query:
SELECT Service_User_ID
FROM service_user
WHERE First_Name = 'test'
AND Last_Name = NULL
AND DOB = '2000-02-12'
AND Address1 = 'qqq'
AND Address2 = 'jjjj'
AND Postcode = NULL
AND Telephone = NULL
AND Mobile_Phone = NULL
AND Faith_ID =1
AND Ethnicity_ID =1
AND Nationality = NULL
AND Gender_ID =1
AND Sexuality_ID =1
AND Disability = NULL
AND Creating_Staff =1;
The record is inserted without problem, but when the select query runs it returns no result. What am I doing wrong. Is it because of the NULLs? when I dont enter nulls for the colums it all works ok. Please help