Consulting

Results 1 to 6 of 6

Thread: (') symbols in insert query

  1. #1

    (') symbols in insert query

    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);

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,066
    Location
    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?

  3. #3
    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?

  4. #4
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,066
    Location
    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.

  5. #5
    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

  6. #6
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,066
    Location
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •