Tags:

How can I avoid NULLs in my database, while also representing missing data?


In SQL and Relational Theory (C.J. Date, 2009) chapter 4 advocates avoiding duplicate rows, and also to avoid NULL attributes in the data we store. While I have no troubles avoiding duplicate rows, I …

Tags:

What does # mean in sql?


Does anyone know what something like OR 1# means in the context of mysql injection?

Insert Fail because of wrong non-numeric character

Tags: , ,


hy table: create table Players (PlayerNo number (4) not null, Name varchar2(15), date_of_birth date,leagno varchar(4)); wrong insert: insert into PLAYERS (PlayerNo,Name,date_of_birth,leagno) …

SQL Server: Why do use SMO?

Tags: , , , ,


I have been working with SQL Server for a couple of years. I have heard about SMO but I don’t know anything about it. What are the benefits of using it? Should I learn and start using SMO in my SQL …

Tags:

Get random object from SQL database via Hibernate


I have following MySql dependent code ( ORDER BY RAND() ) . I would like to know if there is hibernate HQL alternative for it (admin is boolean tag indicating that the user as an admin). This is …

Tags:

mysql query: show summary of all payments made and total of invoices by date


I want this kind of result from these tables. I even can’t figure out how to do it with php. I even tried to join payment and invoice table on date but in vain. It’s a purchase system and this …

SQL Server SELECT LAST N Rows

Tags: , , ,


This is a known question but the best solution I’ve found is something like: SELECT TOP N * FROM MyTable ORDER BY Id DESC I’ve a table with lots of rows. It is not a posibility to use that query …

SQL WHERE clause matching values with trailing spaces

Tags: , , , ,


In SQL Server 2008 I have a table called Zone with a column ZoneReference varchar(50) not null as the primary key. If I run the following query: select ‘”‘ + ZoneReference + ‘”‘ as …

What is dynamic SQL?

Tags: , , ,


I just asked an SQL related question, and the first answer was: “This is a situation where dynamic SQL is the way to go.” As I had never heard of dynamic SQL before, I immediately searched this …

Tags: sql

SQL query that will give me the RecordedValue range each device recorded for each date

Tags:


I have a table with this schema: DeviceID int FloorID int RoomID int DateRecorded datetime RecordedValue decimal A sample of the table’s data looks like: DeviceID FloorID RoomID …