PDA

View Full Version : (') symbols in insert query



alex009988
08-03-2019, 10:29 AM
Hello. I want to add this two lines using sql. The problem is that it contains (') symbals. I also tried using(\') but with no success.
How to add OwpC%9krKZc)n}'@agU{3?c.rsK)2Krd and k`@KFr:V&cu'Sg66qC$IDFYm^zjFt*6J values correctly?


INSERT INTO WiFi_Passwords
VALUES (1, 'OwpC%9krKZc)n}'@agU{3?c.rsK)2Krd', '12345678', HomeWifi')
VALUES (2, 'k`@KFr:V&cu'Sg66qC$IDFYm^zjFt*6J', '12345678', 'HomeWifi);

OBP
08-04-2019, 03:01 AM
I assume that there are 4 fields to be entered?
Is there a particular reason for using an Insert Query rather than direct entry or Copy & paste or VBA code?

alex009988
08-04-2019, 03:42 AM
Year, one is the integer input, the other ones are varchar (255). I think there is a reason, because I should everything do with sql the same as copy past entry.
Are there some restriction on jet sql to do that task?

OBP
08-04-2019, 05:34 AM
Yes the ' symbol designates to SQL that there is text, but has to be in pairs.
to overcome this you have to enclose a singe ' in exclamation marks like this "'".
So I suggest you try playing around with just 1 field at a time untilr you get the syntax correct.
Or use VBA to enter the data.

alex009988
08-05-2019, 03:01 AM
Year, it helped.
Is there a way to insert into several rows?
I've tried this, and it dosent work

INSERT INTO WiFi_Passwords VALUES (1, '2', '3', '4');
INSERT INTO WiFi_Passwords VALUES (1, '2', '3', '4');

this

INSERT INTO WiFi_Passwords (PasswordID, SSID, Passwords, Comments)
SELECT * FROM
(
SELECT 1 AS PasswordID,
'Blackburn sunglasses' AS SSID,
'1' AS Passwords,
'1' AS Comments
FROM WiFi_Passwords
UNION
SELECT 1 AS PasswordID,
'Blackburn sunglasses' AS SSID,
'1' AS Passwords,
'1' AS Comments
FROM WiFi_Passwords


) ;

and it suggest to add zero rows

OBP
08-05-2019, 03:21 AM
The problem may be the Fields that you have as Key indexed fields, assuming you have one or more. They will not allow Duplicates.
The Union is not for adding more than one record it is for Joining Data.
How are you running these Insert Queries?
What is the Table Design Structure?