I’m not sure what should I write in the following SQL query to show ‘date’ column like this: “month-year” – “9-2011”. So, what I want to do is to change the data from the first column to show month and year instead of showing month only. Answer Or as @40-Love me…
Tag: sql
Passing Date from an HTML form to a servlet to an SQL database
I have a problem getting an inputed date (yyyyMMdd) from an HTML form to a sql database via a servlet. The date from the form passes to the servlet as a string but then somehow I need to convert it to date for storing in the database. I have tried a number of methods, date formatter etc.. A possible way
Display an array in a readable/hierarchical format
Here is the code for pulling the data for my array
INSERT with SELECT
I have a query that inserts using a SELECT statement: Is it possible to only select “name, location” for the insert, and set gid to something else in the query? Answer Yes, absolutely, but check your syntax. You can put a constant of the same type as gid in its place, not just 1, of course. And, I…
Case insensitive searching in Oracle
The default behaviour of LIKE and the other comparison operators, = etc is case-sensitive. Is it possible make them case-insensitive? Answer Since 10gR2, Oracle allows to fine-tune the behaviour of string comparisons by setting the NLS_COMP and NLS_SORT session parameters: You can also create case insensitive…
Update statement using with clause
I have a script that uses a stack of with clauses to come up with some result, and then I want to write that result in a table. I just can’t get my head around it, could someone point me in the right direction? Here’s a simplified example that indicates what i want to do: The real thing has quite
how to sort order of LEFT JOIN in SQL query?
OK I tried googling for an answer like crazy, but I couldn’t resolve this, so I hope someone will be able to help. Let’s say I have a table of users, very simple table: and I have another table of their cars and their prices. Now what I need to do is something like this (feel free to rewrite): Whi…
PostgreSQL: SQL script to get a list of all tables that have a particular column as foreign key
I’m using PostgreSQL and I’m trying to list all the tables that have a particular column from a table as a foreign-key/reference. Can this be done? I’m sure this information is stored somewhere in information_schema but I have no idea how to start querying it. Answer This uses the full catal…
Select 2 columns in one and combine them
Is it possible to select 2 columns in just one and combine them? Example: select something + somethingElse as onlyOneColumn from someTable Answer Yes, just like you did: If you queried the database, you would have gotten the right answer. What happens is you ask for an expression. A very simple expression is …
LocalSqlServer was not found in the applications configuration or the connection string is empty
I’ve just upgraded a .NET 3.5 MVC 1 project to .NET 4.0 MVC 3 and for some reason now when I try to run it it says: The connection name ‘LocalSqlServer’ was not found in the applications …