What I’m trying to do is determine (Using Teradata SQL) if a person’s zip code has accidently been put on an address line. I’ve looked on various forums and I can’t find any similar questions. Ultimately, I would want to write something like: Any ideas? Target database is Teradata 13.x…
Tag: sql
How does order by clause works if two values are equal?
This is my NEWSPAPER table. When i run this query It gives this output But in Kevin Loney’s Oracle 10g Complete Reference the output is like this Please help me understand how is it happening? Answer In relational databases, tables are sets and are unordered. The order by clause is used primarily for ou…
SQL Server datatypes nvarchar and varchar are incompatible error
I’ve inherited a C# app which I’ve converted to vb. I get one error which as far as I can see has nothing to do with the conversion. I have a SQL statement which is…. SELECT ResolverID AS …
COUNT DISTINCT with CONDITIONS
I want to count the number of distinct items in a column subject to a certain condition, for example if the table is like this: If I want to count the number of distinct tags as “tag count” and count the number of distinct tags with entry id > 0 as “positive tag count” in the same t…
How to delete a particular label from ltree in Postgres table?
How to delete a particular label from ltree in Postgres table? I have a table? Test table: I want to pass a userid to a query, to remove it from every path in the table. For example, if I pass 101, then 123.101.103 should update as 123.103. Is it possible to do this directly? Or shall I update path using
make text column as unique key
i want to make a table in MySQL server with mediumtext column as UNIQUE KEY but this made an error when I change the type of `name` to varchar .. it works! can you tell if i can to make text column as UNIQUE KEY Answer Basically you can not use Text column as UNIQUE key. Because practically such a
Rename single column in SELECT * in SQL, select all but a column
here is what I’m trying to do- I have a table with lots of columns and want to create a view with one of the column reassigned based on certain combination of values in other columns, e.g. Name, Age, Band, Alive ,,, <too many other fields) And i want a query that will reassign one of the fields, e.g.…
Extracting only date from datetime field (mysql) and assigning it to php variable
I am unable to assign only date to a php variable from datetime field of a MySQL table. I am using PHP 4, I know how to do it in PHP 5. Can someone help as to what is missing from the below php code. …
Make column not nullable in a Laravel migration
I’m writing a migration to make certain columns in a table nullable right now. For the down function, I of course want to make those columns not nullable again. I looked through the schema builder docs, but couldn’t see a way to do this. Any help would be appreciated. Answer Prior to Laravel 5, th…
How do I put an ‘if clause’ in an SQL string?
So here’s what I want to do on my MySQL database. I would like to do: If that would not return any rows, which is possible through if(dr.HasRows == false), I would now create an UPDATE in the purchaseOrder database: How would I be able to make this process a little shorter? Answer For your specific quer…