Professional Web Applications Themes

cfm and mysql 'order' - Coldfusion - Getting Started

Hi I am not sure if this is do with the sql or cfm but I have a simple query: <cfquery name="q1" datasource="mydatasource"> select first_name,second_name, orgname, leadcontact from lastinfo, org_lookup where leadcontact like 'yes' and lastinfo.org_id=org_lookup.org_id order by orgname </cfquery> <cfoutput query="q1"> #orgname# #first_name# #second_nam#<br> </cfoutput> Filed 'leadcontact' is a text field containing 'yes' or 'no', The query as it is written above will not order by orgname as I'm asking it to do, But if I remove the "where leadcontact like 'yes' bit then it will order by orgname. I'm stumped on this one and any advice will be ...

  1. #1

    Default cfm and mysql 'order'

    Hi

    I am not sure if this is do with the sql or cfm but I have a simple query:

    <cfquery name="q1" datasource="mydatasource">
    select first_name,second_name, orgname, leadcontact from lastinfo, org_lookup
    where leadcontact like 'yes' and lastinfo.org_id=org_lookup.org_id order by
    orgname
    </cfquery>

    <cfoutput query="q1">
    #orgname# #first_name# #second_nam#<br>
    </cfoutput>

    Filed 'leadcontact' is a text field containing 'yes' or 'no', The query as it
    is written above will not order by orgname as I'm asking it to do, But if I
    remove the "where leadcontact like 'yes' bit then it will order by orgname. I'm
    stumped on this one and any advice will be gratefully received!

    Regards

    Dave

    Dave199 Guest

  2. #2

    Default Re: cfm and mysql 'order'

    Why don't you just use where leadcontact = 'yes' ?


    BKBK Guest

  3. #3

    Default Re: cfm and mysql 'order'

    > I am not sure if this is do with the sql or cfm but I have a simple query:

    No issue that is related to getting unexepected query results when changing
    SQL statements will be due to CF. CF doesn't do anything with the SQL
    other than pass it to the DB, and wait for the DB to pass something back.
    It's a "don't shoot the messenger" kinda situation.

    What do you get if you put your SQL through MySQL Query Browser?

    --
    Adam
    Adam Guest

  4. #4

    Default Re: cfm and mysql 'order'

    I don't know why it's not sorting but you'll get your wrong answer more quickly if you change
    where leadcontact like 'yes'
    to
    where leadcontact = 'yes'
    Dan Guest

Similar Threads

  1. Order statistic in MySQL
    By Jeffrey Rolland in forum MySQL
    Replies: 13
    Last Post: April 25th, 04:00 PM
  2. Replies: 0
    Last Post: January 29th, 02:03 PM
  3. Replies: 10
    Last Post: November 2nd, 10:32 AM
  4. MYSQL query using GROUP BY and ORDER BY?
    By Bonge Boo! in forum PHP Development
    Replies: 3
    Last Post: August 15th, 06:12 PM
  5. problem with DBI.pm and ORDER BY RAND() in mysql
    By Joe Blower in forum PERL Miscellaneous
    Replies: 1
    Last Post: July 13th, 11:06 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139