Usage of the " IN " operator

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Usage of the " IN " operator

    Permits contains a string: 4,16,12,9,12,7,5 .....
    cookie.userid is a number

    <cfquery name="rsTitols" datasource="gallery">
    SELECT * FROM Galleries
    WHERE '#cookie.userid#' in(SELECT permits from Galleries)
    </cfquery>

    does not produce an error but doesn't return any value.
    Should value in "permits" be quote delimited with ListQualify()?
    How do I do that?

    Thank you very much.

    Conti Guest

  2. Similar Questions and Discussions

    1. #39018 [NEW]: Error control operator '@' fails to suppress "Uninitialized string offset"
      From: mpb dot mail at gmail dot com Operating system: Gentoo Linux PHP version: 5.1.6 PHP Bug Type: Scripting Engine problem...
    2. vb.net: Problem using "IS" operator with ? parameter in Dataset
      I'm sure someone's come across this, but I couldn't find it searching the boards. I get the error message "Invalid use of Is operator in query...
    3. offending operator "nary"
      Upon opening a file for a catalog I am working on an error came on the screen. It said: offending operator "nary" Content: XH %AI5_End Raster...
    4. #26122 [Opn->Bgs]: Logical Operator "and" not functioning as expected
      ID: 26122 Updated by: iliaa@php.net Reported By: iam at nimajneb dot com -Status: Open +Status: ...
    5. #26122 [NEW]: Logical Operator "and" not functioning as expected
      From: iam at nimajneb dot com Operating system: Mac OSX 10.2.6 PHP version: 4.3.2 PHP Bug Type: Math related Bug...
  3. #2

    Default Re: Usage of the " IN " operator

    Very bad data model/design. Is there any way that you could avoid having a comma delimited list in the permits field?

    Phil
    paross1 Guest

  4. #3

    Default Re: Usage of the " IN " operator

    You are right Phil. The newbie here.

    At creation, I need to relate a record in table Galleries to a certain number
    of users in table Users.
    Basics I suppose. Could you give me an hint.

    Thnak you very much.
    Wal

    Conti Guest

  5. #4

    Default Re: Usage of the " IN " operator

    So I am assuming that there is a many-to-many relationship between Galleries
    and users. (More than one user can be associated with more than one gallery,
    and vice versa.) You should create a "link" table (associative entity) that
    contains, at a minimum, the PK field of the Galleries table and the PK field of
    the users table (I am assuming that Galleries has a primary key). Call this
    GalleryUsers. Then for every case where you have a user associated to a
    gallery, you would insert a row with the userID and galleryID. Then you could
    join Galleries, Users, and GalleryUsers in a query to select users associated
    with a gallery, or galleries associated with a particular user, or all
    galleries and users, etc.

    For example, something like this would allow you to list the galleries that
    are associated with a particuar user:

    SELECT g.gallery_name
    FROM users u, Galleries g, GalleryUsers gu
    WHERE gu.galleryID = g.galleryID
    AND gu.userID = u.userID
    AND u.user_name = '#UserName#'

    Phil

    paross1 Guest

Posting Permissions

  • You may not post new threads
  • You may 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