Re: Return Counts Different In Similar SQL Statements

From: Vishal Parkar (REMOVE_THIS_vgparkar_at_yahoo.co.in)
Date: 03/19/04

  • Next message: Bruce Rose: "Re: Return Counts Different In Similar SQL Statements"
    Date: Sat, 20 Mar 2004 01:20:30 +0530
    
    

    hi bruce,

    select count1 = count(*) FROM ##junk
    WHERE (LastName = @sLastName )

    Above query will look for match for the string ''smith''(ie anything within the single quotes
    will be compared, which does not exists in the table. you need to add '' (2 single quotes) in
    the string to use it in the dynamic sql(to get the effect of single quote). so that your
    dynamically created string can be formed as

    select count2 = count(*) FROM ##junk WHERE (LastName = 'smith')

    Use print statement to see what is the dynamically generated string looks like:
    Ex:
    print @s

    in short 2 single quotes gives you the effect of 1 single quote while dynamically running
    query, this is not the case while running the normal query and your select statement will be
    run as follows, which will obviously return 0.

    select count1 = count(*) FROM ##junk
    WHERE (LastName = ''smith'' )

    -- 
    Vishal Parkar
    vgparkar@yahoo.co.in
    

  • Next message: Bruce Rose: "Re: Return Counts Different In Similar SQL Statements"

    Relevant Pages

    • Re: javascript in a querys text string
      ... Now, can you please explain to me how to limit the contents of the column shown the text string so, only the cells where the record's.Value Is Null? ... double each internal double-quote, and don't change the single quotes, ... page) there is a query displaying the first four fields. ... The general idea is that I don't know how to replace/escape the ...
      (comp.databases.ms-access)
    • Re: parameter query not prompting for parameter
      ... The single quotes were actually put in there by Access when I entered the ... try to save the query, ... > parameter literally as a string". ... us a control on a form as a criteria in your query. ...
      (microsoft.public.access.queries)
    • Re: Mandis Quotes (aka retiring """ and )
      ... > surround the string by a pair of doubled single quotes. ... > an arbitrary string in-between the single quotes which does NOT ... > of ASCII or Unicode characters, but instead as a sequence of lines ...
      (comp.lang.python)
    • Re: javascript in a querys text string
      ... contents of the column shown the text string so, ... "Larry Linson" mounted the rostrum and spoke like this: ... double each internal double-quote, and don't change the single quotes, ... page) there is a query displaying the first four fields. ...
      (comp.databases.ms-access)
    • Re: quotes from form input + MySQL insert query
      ... string mysql_escape_string ... > same way, but a textarea string full of single quotes is handled fine, while ... I've checked the POSTed data by echoing ... > backslashes, in case the single ones generated by magic_quotes weren't ...
      (alt.php)