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. General Programming
  3. C#
  4. query

query

Scheduled Pinned Locked Moved C#
databasetutorial
18 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.
  • L lankaudaranga

    how to wright this query "select * from stock_in where result NOT EQUALS 'YES'"

    H Offline
    H Offline
    Harvey Saayman
    wrote on last edited by
    #3

    first off your in the wrong forum, try SQL secondly NEVER SELECT * FROM

    Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

    A J 2 Replies Last reply
    0
    • H Harvey Saayman

      first off your in the wrong forum, try SQL secondly NEVER SELECT * FROM

      Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #4

      Harvey Saayman wrote:

      secondly NEVER SELECT * FROM

      Unless you have a very good reason - and yes, there are times when you need to do it, but not in your normal run of the mill applications.

      Bob Ashfield Consultants Ltd

      H 1 Reply Last reply
      0
      • A Ashfield

        Harvey Saayman wrote:

        secondly NEVER SELECT * FROM

        Unless you have a very good reason - and yes, there are times when you need to do it, but not in your normal run of the mill applications.

        Bob Ashfield Consultants Ltd

        H Offline
        H Offline
        Harvey Saayman
        wrote on last edited by
        #5

        Ashfield wrote:

        and yes, there are times when you need to do it

        like when? :doh:

        Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

        G A 2 Replies Last reply
        0
        • H Harvey Saayman

          first off your in the wrong forum, try SQL secondly NEVER SELECT * FROM

          Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

          J Offline
          J Offline
          J4amieC
          wrote on last edited by
          #6

          You realise how legacy the "never select *" rule is right? Back in SQL 7 (circa 1997), it caused an extra round trip to the server to determine the table schema before doing the actual data select. By SQL 2000 they had fixed this issue and it ceased to be a problem. As far as good practice goes, I totally agree with you. As far as a bolded+uppercase NEVER goes, sorry, you're wrong.

          H 1 Reply Last reply
          0
          • J J4amieC

            You realise how legacy the "never select *" rule is right? Back in SQL 7 (circa 1997), it caused an extra round trip to the server to determine the table schema before doing the actual data select. By SQL 2000 they had fixed this issue and it ceased to be a problem. As far as good practice goes, I totally agree with you. As far as a bolded+uppercase NEVER goes, sorry, you're wrong.

            H Offline
            H Offline
            Harvey Saayman
            wrote on last edited by
            #7

            J4amieC wrote:

            circa 1997

            I was 9 back then ;P Its just a practice i was taught and it stuck, and if these newbies get used to SELECT * FROM and they one day work on or with big databases (like the systems you'll come across at the data warehouse of an insurance company) they will bring it down! Ive heard about things like this being common from my step mom who's a data modeler.

            Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

            J 1 Reply Last reply
            0
            • H Harvey Saayman

              Ashfield wrote:

              and yes, there are times when you need to do it

              like when? :doh:

              Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #8

              For example when you have a sub query. In that case the fields are specified in the sub query and doesn't need to be repeated in the query.

              select *
              from (
              select top 10 SomeField, AnotherField
              from SomeTable
              order by SomeField asc
              ) x
              order by SomeField desc

              Despite everything, the person most likely to be fooling you next is yourself.

              H 1 Reply Last reply
              0
              • G Guffa

                For example when you have a sub query. In that case the fields are specified in the sub query and doesn't need to be repeated in the query.

                select *
                from (
                select top 10 SomeField, AnotherField
                from SomeTable
                order by SomeField asc
                ) x
                order by SomeField desc

                Despite everything, the person most likely to be fooling you next is yourself.

                H Offline
                H Offline
                Harvey Saayman
                wrote on last edited by
                #9

                okay that makes sense, cause your just selecting everything returned from the sub query...

                Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

                1 Reply Last reply
                0
                • H Harvey Saayman

                  J4amieC wrote:

                  circa 1997

                  I was 9 back then ;P Its just a practice i was taught and it stuck, and if these newbies get used to SELECT * FROM and they one day work on or with big databases (like the systems you'll come across at the data warehouse of an insurance company) they will bring it down! Ive heard about things like this being common from my step mom who's a data modeler.

                  Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

                  J Offline
                  J Offline
                  J4amieC
                  wrote on last edited by
                  #10

                  Harvey Saayman wrote:

                  I was 9 back then

                  I know you were, ow stop making me feel old!

                  Harvey Saayman wrote:

                  they will bring it down

                  bring it down how? Essentially nowdays Select * is identical to select col1,col2...

                  H 1 Reply Last reply
                  0
                  • H Harvey Saayman

                    Ashfield wrote:

                    and yes, there are times when you need to do it

                    like when? :doh:

                    Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

                    A Offline
                    A Offline
                    Ashfield
                    wrote on last edited by
                    #11

                    A simple example, when you are extracting a subset of data to a file for any reason. As I said, not the normal run of the mill applications, and I agree you shouldn't use it normally, but, as they say, never say never :)

                    Bob Ashfield Consultants Ltd

                    C 1 Reply Last reply
                    0
                    • J J4amieC

                      Harvey Saayman wrote:

                      I was 9 back then

                      I know you were, ow stop making me feel old!

                      Harvey Saayman wrote:

                      they will bring it down

                      bring it down how? Essentially nowdays Select * is identical to select col1,col2...

                      H Offline
                      H Offline
                      Harvey Saayman
                      wrote on last edited by
                      #12

                      J4amieC wrote:

                      I know you were, now stop making me feel old!

                      bwhahahaha, sorry... :laugh:

                      J4amieC wrote:

                      bring it down how?

                      SELECT *
                      FROM table1
                      JOIN table2
                      ON someCondition
                      JOIN table3
                      ON someOtherCondition

                      If you pull that kinda crap (and sadly it happens) on DB's containing terra's upon terra's of data...

                      Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

                      J 1 Reply Last reply
                      0
                      • H Harvey Saayman

                        J4amieC wrote:

                        I know you were, now stop making me feel old!

                        bwhahahaha, sorry... :laugh:

                        J4amieC wrote:

                        bring it down how?

                        SELECT *
                        FROM table1
                        JOIN table2
                        ON someCondition
                        JOIN table3
                        ON someOtherCondition

                        If you pull that kinda crap (and sadly it happens) on DB's containing terra's upon terra's of data...

                        Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

                        J Offline
                        J Offline
                        J4amieC
                        wrote on last edited by
                        #13

                        Ok, I see your point, but its not the * thats the issue its the pulling of all fields from a large query. Someone stupid enough to do that would follow your advice and just write:

                        SELECT [very long list of column names]
                        FROM table1
                        JOIN table2
                        ON someCondition
                        JOIN table3
                        ON someOtherCondition

                        Now leave me in peace you little whipper-snapper.

                        H 1 Reply Last reply
                        0
                        • J J4amieC

                          Ok, I see your point, but its not the * thats the issue its the pulling of all fields from a large query. Someone stupid enough to do that would follow your advice and just write:

                          SELECT [very long list of column names]
                          FROM table1
                          JOIN table2
                          ON someCondition
                          JOIN table3
                          ON someOtherCondition

                          Now leave me in peace you little whipper-snapper.

                          H Offline
                          H Offline
                          Harvey Saayman
                          wrote on last edited by
                          #14

                          J4amieC wrote:

                          Now leave me in peace you little whipper-snapper.

                          lol, i had to go google [define:"whipper snapper"] :laugh: cheers bud

                          Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

                          J 1 Reply Last reply
                          0
                          • H Harvey Saayman

                            J4amieC wrote:

                            Now leave me in peace you little whipper-snapper.

                            lol, i had to go google [define:"whipper snapper"] :laugh: cheers bud

                            Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

                            J Offline
                            J Offline
                            J4amieC
                            wrote on last edited by
                            #15

                            damn, after doing that it soudsn kinda insulting. I didn't mean it that way. :|

                            H 1 Reply Last reply
                            0
                            • J J4amieC

                              damn, after doing that it soudsn kinda insulting. I didn't mean it that way. :|

                              H Offline
                              H Offline
                              Harvey Saayman
                              wrote on last edited by
                              #16

                              its all good, didn't think you did

                              Harvey Saayman - South Africa Junior Developer .Net, C#, SQL you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer) 1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111

                              1 Reply Last reply
                              0
                              • A Ashfield

                                A simple example, when you are extracting a subset of data to a file for any reason. As I said, not the normal run of the mill applications, and I agree you shouldn't use it normally, but, as they say, never say never :)

                                Bob Ashfield Consultants Ltd

                                C Offline
                                C Offline
                                Colin Angus Mackay
                                wrote on last edited by
                                #17

                                Ashfield wrote:

                                when you are extracting a subset of data to a file for any reason

                                Including when I only want a subset of the columns?

                                Recent blog posts: *SQL Server / Visual Studio install order *Installing SQL Server 2005 on Vista *Crazy Extension Methods Redux * Mixins My Blog

                                A 1 Reply Last reply
                                0
                                • C Colin Angus Mackay

                                  Ashfield wrote:

                                  when you are extracting a subset of data to a file for any reason

                                  Including when I only want a subset of the columns?

                                  Recent blog posts: *SQL Server / Visual Studio install order *Installing SQL Server 2005 on Vista *Crazy Extension Methods Redux * Mixins My Blog

                                  A Offline
                                  A Offline
                                  Ashfield
                                  wrote on last edited by
                                  #18

                                  Not really, I was replying t a cmment that said NEVER use select *

                                  Bob Ashfield Consultants Ltd

                                  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