Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2010
    Posts
    8

    Unanswered: query problem (int to text)

    Hey There,

    SELECT wu_roster_registrar.discipline ||' '|| wu_roster_registrar.course_num ||''|| wu_roster_registrar.crs_section
    as "course and section", crs_cd, schedule.lastname, divisions_view.name
    FROM public.wu_roster_registrar, public.schedule, public.divisions_view
    where wu_roster_registrar.course_num = schedule.course_num and schedule.school = divisions_view.id
    go
    The schedule table the school as a text format and division_view table has id is int4 format. that's why it's giving me an ERROR as: operator does not exist: text = integer

    School Course and Section Course Code Instructor Last Name
    ------ ------------------- ----------- --------------------
    BUSINESS ACC2203 S0B4A 0003 moraci
    BUSINESS ACC2203 S0C4A 0004 moraci
    I don't know what to do......help me please!!!!!

    Best,
    Rusan

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Quote Originally Posted by Rusan View Post
    The schedule table the school as a text format and division_view table has id is int4 format. that's why it's giving me an ERROR as: operator does not exist: text = integer
    Why do you store numbers in a text field? Shouldn't the school column be an int4 as well if it references the id column?

  3. #3
    Join Date
    Aug 2010
    Posts
    8
    I know. However, the tables are set up in this way.....I can not change it. I have to generate query out of this.

  4. #4
    Join Date
    Aug 2009
    Location
    Olympia, WA
    Posts
    337
    cast it.
    Code:
    schedule.school::int = divisions_view.id -- Postgres extension
    or
    CAST(schedule.school AS int) = divisions_view.id -- SQL standard

  5. #5
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Quote Originally Posted by Rusan View Post
    I know. However, the tables are set up in this way.....I can not change it. I have to generate query out of this.
    I still don't understand: how can a character value reference an integer value
    Your example shows the value "BUSINESS" for the school column. How can that possibly relate to an integer id column?

  6. #6
    Join Date
    Aug 2010
    Posts
    8
    artacus72,
    Thank you su much! you are a savior.

Posting Permissions

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