sql

MySQL #1140 - Mixing of GROUP columns

Hi wondering if perhaps someone could shed some light on the below error. The sql works fine locally but i get the the below error remotely. SQL query: SELECT COUNT(node.nid), node.nid AS nid, node_data_field_update_date.field_update_date_value AS node_data_field_update_date_field_update_date_value FROM ...

IF statement in ORDER BY Clause of a SELECT Statement in a SQL Server Stored Procedure

I am trying to create a stored procedure that takes a bit parameter which if true orders by one column and if false orders by another column. How would I implement this? Here is what I have so far CREATE PROCEDURE [dbo].[CLICK10_GetCP] @switch AS BIT AS BEGIN SELECT acct_nbr, acct_name FROM acct ...

C#: Is it possible to store a Decimal Array in an SQL database?

Hi there, I'm working on an application for a lab project and I'm making it in C#. It's supposed to import results from a text file that is exported from the application we use to run the tests and so far, I've hit a road block. I've gotten the program to save around 250 decimal values as a single-dimension array but then I'm trying to...

SQL Pivot table

Is there a way to pivot an Entity-Attribute table? I want to flip all the rows into columns, regardless of how many different attributes there are. Here's an example of what I want to accomplish. The example uses two attributes: FirstName, LastName. But in the real database, there are thousands of attributes and I want to flip them ...

Character Support Issue - How to Translate Higher ASCII Characters to Lower ASCII Characters

So I have an ASP.Net (vb.net) application. It has a textbox and the user is pasting text from Microsoft Word into it. So things like the long dash (charcode 150) are coming through as input. Other examples would be the smart quotes or accented characters. In my app I'm encoding them in xml and passing that to the database as an xml p...

Why does LIKE not return rows for variables with '%' at end?

I find this quite odd on Microsoft SQL Server: SELECT * FROM deliveries WHERE code LIKE '01999195000%' -- 9 rows returned. Works. DECLARE @a VARCHAR(10) SET @a='01999195000%' SELECT * FROM deliveries WHERE code LIKE @a -- 0 rows returned? Why not? SET @a = '01999195000' SELECT * FROM deliveries WHERE code LIKE @a + '%' -- 9 rows retur...

Sequence within SQL Select

Afternoon Gents. I'm having a bit of a problem with using my sequence within a SELECT statement. SELECT c.cust_name, c.site, customer_id_seq.nextval FROM customer c WHERE c.customer_id IS NULL ORDER BY c.site_code ASC ; Is giving me an error: 00000 - "sequence number not allowed here" *C...

What nosql means? can someone explain it to me in simple words?

in this post Stack Overflow Architecture i read about something called nosql, i didn't understand what it means, and i tried to search on google but seams that i can't get exactly whats it. Can anyone explain what nosql means in simple words? ...

LINQ to SQL C# COALESCE

Given the following table: Length | Width | Color | ID =========================== 18 | 18 | blue | 1 --------------------------- 12 | 12 | red | 1 --------------------------- I want to produce a single column/row: SIZES ================= 18 x 18, 12 x 12, I can do this in SQL as follows: DECLARE @SIZES VARCH...

relationships in Sql

I know how to create one to many, many to many relationships in SQL Server, but is it possible to create one to one relationship? And is it possible to create 1 to 0 or 1 relationship? ...

How do I retrieve images within Postgres into Matlab using Java?

Hi, I have been given a bit of a strange task, there are around 1500-2000 jpeg images all of around 1-50kb in size. They are currently stored in a simple database I made with Postgres. It's been a long time since I used Matlab and Postgres heavily so any help or suggestions is really appreciated! I need to get the images that are store...

Linq2Sql: How to handle tables with the same name and different schema names

I have a database with multiple tables which have the same name but are from different schemas. For example: [DatabaseName].[Schema1].[MyTable] [DatabaseName].[Schema2].[MyTable] When Linq2Sql generates code for this database, it appears to just be picking up the table from the first schema and completely ignoring the second schema: ...

Why a simple T-SQL UDF function makes the code execution 3 times slower

Hi folks, I'm rewriting some old stored procedure and I've come across an unexpected performance issue when using a function instead of inline code. The function is very simple as follow: ALTER FUNCTION [dbo].[GetDateDifferenceInDays] ( @first_date SMALLDATETIME, @second_date SMALLDATETIME ) RETURNS INT AS BEGIN RETURN ABS(DA...

Help with this JOIN

$threads = mysql_query("SELECT DISTINCT t.id, t.title FROM threads t LEFT JOIN comments c ON t.id = c.parentID ORDER BY c.date DESC"); while ($thread = mysql_fetch_assoc($threads)) { echo "<li><a href=\"?threadID=$thread[id]\">".htmlspecialchars($thread['title'])."</a></li>\n"; } Can ...

Using math functions in Sql with MS Access

I designed a query in SQL View using MS Access: select floor(num1) from t1; When I run it, I get "undefined function floor". I get similar errors for Ceil, Mod,Power, Sign, Sqrt, Trunc, and initcap functions. Does the Access database engine's SQL syntax have equivalent functions? ...

Updating an UNPIVOTted SQL Table

Okay, I've been beating my head against this, and I'm sure I'm just missing something obvious, but... I have a table in a customer's database, that's basically: Item_Set_Key int Item_1 bit Notes_1 nvarchar(80) Item_2 bit Notes_2 nvarchar(80) Item_3 bit Notes_3 nvarchar(80) ... There's 99 items in ea...

ORACLE How to use spool with dynamic spool location.

Ok, so i'm a complete newb with oracle. Now that that's out of the way; I think you can get an understand of what i'm trying to do below. For each stored procedure found, output the DDL to a filename with it's name. The problem is i can't figure out how to get the spool target to pick up the value of FileName which is being set by the ...

How to do this kind of query?

A user can have suspensions. I want to select a user and his suspensions, but I only want the suspensions where the suspensions.suspended_date > now(). I want to return the user regardless. It sounds like a left join, but: SELECT * FROM users LEFT JOIN suspensions ON suspensions.user_id=users.id WHERE suspensions.suspended_date > now()...

How do I make one user see a different table with same name

Goal: When everybody else does SELECT * FROM mytable they see one version of the table. But when a specific user does SELECT * FROM mytable they see another version of the table. I think I'm like halfway there with creating a new role and putting the single user in it. Then creating a copy of the default table with SELECT * INTO newro...

What is faster query ...where Fname = 'mark' or ...where Fname like 'mark'

hi What is faster query select...where Fname = 'mark' or select...where Fname like 'mark' thank's ...