Re: [sqlite] selective result columns
I'm operating at the user level in a java application. The application allows me to run an SQL query, then it renders the output into HTML. I want to avoid showing empty colums in the HTML output, so I wanted the include/exclude column logic in my actual SQL statement. Pavel Ivanov-2 wrote: > >> I don't have access to that level of software, so that's the problem. > > You mean your experience with SQLite is based on using sqlite3 command > line utility only? If so you can just redirect its output to sed which > will do something like s/|\+/|/g. > If your experience with SQLite is based on using some other kind of > software then you cannot do anything with it - it will inevitably rely > on the fact that each row has the same number of columns and it will > show you all of these columns... > > In any case as you probably have understood already you better to tell > us what you're trying to achieve in general and what software you're > working with so that we could provide a better general advice that > doesn't involves such action as "removing columns without useful > information from result set"... > > > Pavel > > On Tue, Dec 29, 2009 at 4:34 PM, nomorecaddy <nomoreca...@yahoo.com> > wrote: >> >> I don't have access to that level of software, so that's the problem. >> Thanks >> for your response - I like the power of select case, and was hoping that >> case could be applied in other areas as well. >> >> >> >> Simon Slavin-3 wrote: >>> >>> >>> On 29 Dec 2009, at 8:34pm, nomorecaddy wrote: >>> >>>> I'm looking for a SQL query that returns a variable number of >>>> columns. Many of my columns contain NULL data, and I want to avoid >>>> showing >>>> the column altogether in that case. >>> >>> That is something that must be handled by your software. There is no >>> way >>> in SQL to return an answer to a SELECT which has a different number of >>> columns in different records. You could make SQL return columns with >>> NULL >>> in and your software could automatically recognise them and know not to >>> print them. >>> >>> Remember that SQL is a database engine. It's job is to supply data. >>> It's >>> your software's job to understand what needs to be done with it. >>> >>> Simon. >>> ___ >>> sqlite-users mailing list >>> sqlite-users@sqlite.org >>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users >>> >>> >> >> -- >> View this message in context: >> http://old.nabble.com/selective-result-columns-tp26958131p26960765.html >> Sent from the SQLite mailing list archive at Nabble.com. >> >> ___ >> sqlite-users mailing list >> sqlite-users@sqlite.org >> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users >> > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > -- View this message in context: http://old.nabble.com/selective-result-columns-tp26958131p26980075.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] selective result columns
I don't have access to that level of software, so that's the problem. Thanks for your response - I like the power of select case, and was hoping that case could be applied in other areas as well. Simon Slavin-3 wrote: > > > On 29 Dec 2009, at 8:34pm, nomorecaddy wrote: > >> I'm looking for a SQL query that returns a variable number of >> columns. Many of my columns contain NULL data, and I want to avoid >> showing >> the column altogether in that case. > > That is something that must be handled by your software. There is no way > in SQL to return an answer to a SELECT which has a different number of > columns in different records. You could make SQL return columns with NULL > in and your software could automatically recognise them and know not to > print them. > > Remember that SQL is a database engine. It's job is to supply data. It's > your software's job to understand what needs to be done with it. > > Simon. > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > -- View this message in context: http://old.nabble.com/selective-result-columns-tp26958131p26960765.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] selective result columns
Thanks, I'm looking for a SQL query that returns a variable number of columns. Many of my columns contain NULL data, and I want to avoid showing the column altogether in that case. Simon Slavin-3 wrote: > > > On 29 Dec 2009, at 6:29pm, nomorecaddy wrote: > >> Is it possible to run an SQL query in sqlite that displays columns only >> on a >> condition? For example: >> select col1, (case when 1==2 then col2) from myTable >> >> In this case, I only want to show one column (col1) > > I'm not sure I understand your question, but I'll guess. A SELECT command > must return the same number of columns in each row. You can use a > conditional function to change what appears in each row and your CASE is > fine, but you need to correct the syntax: > > http://sqlite.awardspace.us/syntax/sqlitepg09.htm > > Simon. > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > -- View this message in context: http://old.nabble.com/selective-result-columns-tp26958131p26959565.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] selective result columns
Is it possible to run an SQL query in sqlite that displays columns only on a condition? For example: select col1, (case when 1==2 then col2) from myTable In this case, I only want to show one column (col1) Thanks -- View this message in context: http://old.nabble.com/selective-result-columns-tp26958131p26958131.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users