Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. like query

like query

Scheduled Pinned Locked Moved Database
helpdatabaseannouncement
7 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brettokumar
    wrote on last edited by
    #1

    hi my data field is integer i give a query like this select * from news where newsid like '123%' it display error i want to display news where my newsid is start with 123 please help me

    L P Z 3 Replies Last reply
    0
    • B brettokumar

      hi my data field is integer i give a query like this select * from news where newsid like '123%' it display error i want to display news where my newsid is start with 123 please help me

      L Offline
      L Offline
      leoinfo
      wrote on last edited by
      #2

      There is nothing wrong with the code you posted ... what error do you get?

      M 1 Reply Last reply
      0
      • B brettokumar

        hi my data field is integer i give a query like this select * from news where newsid like '123%' it display error i want to display news where my newsid is start with 123 please help me

        P Offline
        P Offline
        Paddy Boyd
        wrote on last edited by
        #3

        You need to cast your newsid to varchar.

        T 1 Reply Last reply
        0
        • P Paddy Boyd

          You need to cast your newsid to varchar.

          T Offline
          T Offline
          TheFM234
          wrote on last edited by
          #4

          I was thinking the same thing, but like implicitly coverts int's to varchar. I think it would help a lot if we knew what the error is instead of guessing.

          M 1 Reply Last reply
          0
          • L leoinfo

            There is nothing wrong with the code you posted ... what error do you get?

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            Yes there is the like operator is not valid agains a numeric or date field. Note the field is an integer. Either turn it into a varchar or use numeric operators

            Never underestimate the power of human stupidity RAH

            1 Reply Last reply
            0
            • T TheFM234

              I was thinking the same thing, but like implicitly coverts int's to varchar. I think it would help a lot if we knew what the error is instead of guessing.

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #6

              Scott Clewell wrote:

              but like implicitly coverts int's to varchar

              Ok - I was not aware of that, it still feels like he is attempting the wrong thing, I would never rely on an implicit conversion there is a cost in the implicit conversion that I find unacceptable and the bloody thing will bite you sometime in the future.

              Never underestimate the power of human stupidity RAH

              1 Reply Last reply
              0
              • B brettokumar

                hi my data field is integer i give a query like this select * from news where newsid like '123%' it display error i want to display news where my newsid is start with 123 please help me

                Z Offline
                Z Offline
                zahedonline
                wrote on last edited by
                #7

                i got it why you got this error!!! You cannot use a Like wild card with Integers .. is ur newsid is int? Cheers,

                ZAK

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups