query
-
how to wright this query "select * from stock_in where result NOT EQUALS 'YES'"
-
how to wright this query "select * from stock_in where result NOT EQUALS 'YES'"
-
how to wright this query "select * from stock_in where result NOT EQUALS 'YES'"
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 -
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 -
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
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 -
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 111111You 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.
-
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.
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 -
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 111111For 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 descDespite everything, the person most likely to be fooling you next is yourself.
-
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 descDespite everything, the person most likely to be fooling you next is yourself.
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 -
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 -
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 -
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...
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 someOtherConditionIf 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 -
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 someOtherConditionIf 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 111111Ok, 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 someOtherConditionNow leave me in peace you little whipper-snapper.
-
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 someOtherConditionNow leave me in peace you little whipper-snapper.
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 -
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 -
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 -
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
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
-
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