sql

DATEPART not working like i think it must

select * from Advertisements where DepartureDate < DATEPART('dd.mm.yy', '09.10.2010'); but i get Msg 1023, Level 15, State 1, Line 1 Invalid parameter 1 specified for datepart. in plsql is this very simple here is so complicated... Can someone tell me please how can i get all dates that are smaller than today. ...

How Can I Split Decimal Value from Integer Value?

Assume i have 4.9 value. I would like to split 4 and .9 ... How can i do it? I could isolate 4 by using FLOOR(). What about the .9? How can i isolate it? I'm using t-sql sql server 2005/2008 ...

need good sql library for php

hello, SO need library like crystal (crystal-project.net). at this time i use crystal, but this library not really for me at the moment (bad join and table prefix support, don't have function for get rows count). i don't need in ORM or abstraction library. i just need good mysql wrapper with chain method support (->order_by('-id')->li...

Generating a table given a user input range (dates), then attaching 24H (column 2) to each date

I had asked this prior, but I think I worded it poorly or perhaps not clearly enough. I'm pretty new to Access and SQL, but I'm pretty adept with computers. I've read a few books/websites on Access/SQL, but I'm finding this problem a bit difficult. This would be a lot easier if it was a simple SELECT range, but the scenario wants me to g...

MySQL creating and populating the database

Hi, I have downloaded the MySQL 5.2.5.1 version. I need to create the database and populate it. O have the data file in .csv format. I'm running the Mysql on windows. So when I create the database and a table in it, I want to populate the data from a file on my PC which is in .csv format. I did it in this way: load data local infile 'un...

MYSQL -populating the database

How do we populate the data into mySql windows 5.1. version?I have .csv files. I'm not allowed to use the load data command. Please help me out. ...

SQL: Proper Join Syntax

Suppose I have two tables, one with blog posts and another with readers and their comments: Table 1: table name: BlogPosts: structure: id (int) title (string) Table 2: table name: Readers: id (int) blog_post_id (int) name (string) comment (string) in the Readers table there is a unique composite key on blog_post_id/name (i.e....

Representing a DAG (directed acyclic graph)

I need to store dependencies in a DAG. (We're mapping a new school curriculum at a very fine grained level) We're using rails 3 Considerations Wider than it is deep Very large I estimate 5-10 links per node. As the system grows this will increase. Many reads, few writes most common are lookups: dependencies of first and secon...

Question Regarding Fetching Records based on Date Range

SELECT COUNT(td.timeSheetID) FROM TimeSheet t INNER JOIN TimeSheetDetail td ON t.timeSheetID = td.timeSheetID WHERE (CONVERT(DateTime, t.setDate, 23) BETWEEN '2012-08-10' AND '2012-08-12') AND t.employeeID = 300 The above code returns the value i'm looking for. However, when i do the following, i get nothing: SELECT COUNT(td.ti...

how to best organize the Inner Joins in (select) statement

let's say i have three tables, each one relates to another, when i need to get a column from each table, does it make difference how to organize the (inner joins)?? Select table1.column1,table2.column2,table3.column2 From table1 Inner Join table2 on ..... etc Inner Join table3 on ..... in another words, can i put (table2) after (Fro...

Linq to SQL: Get number of consecutive daily views

I have a table that records when a user views a page. The table looks something like this: ID | Date 1 | 01/01/10 00:00:01.000 2 | 03/01/10 00:00:01.000 3 | 03/01/10 00:00:02.000 4 | 04/01/10 00:00:01.000 5 | 05/01/10 00:00:01.000 6 | 05/01/10 00:00:02.000 7 | 05/01/10 00:00:03.000 Using Linq-to-SQL I want to count the last gro...

T-SQL Operators LIKE need help

i would like to search in DB input string is "oxoşil" o -> [o-ö] x -> [x-ks] ş -> [s-ş] ş -> [ş-sh] i need to search all of these cominations. Needed finally search criteria is [o-ö][x-ks][o-ö][ş-s-sh][i-ı]l is there any way to to this with t-sql like operator? or in linq? ...

1Z0-007 exam question

Question: In which four clauses can a subquery be used? (Choose four.) A. in the INTO clause of an INSERT statement B. in the FROM clause of a SELECT statement C. in the GROUP BY clause of a SELECT statement D. in the WHERE clause of a SELECT statement E. in the SET clause of an UPDATE statement F. in the VALUES clause of an ...

MySQL get only rows with a unique value for a certain field

Hi, I want to get only the rows with a unique value for a certain field (2 actually). My table is like this: id senderID receiverID ... ... ... _________________________________________________ 0 0 1 ... ... ... 1 2 1 ... ... ... 2 1 0 ...

Need help in forumlating the query output in a certain fashion

We have a table which contains TV channel listings. create table listing (id, channel_name, event_name, event_time) a) listing (1, "ABC Channel", "All My Children", 6.00 AM) b) listing (2, "ABC Channel", "News", 7 AM) c) listing (3, "ABC Channel", "One life to live", 7.15 AM) d) listing (4, "ABC Channel", "General Hospital", 8.00 AM) e...

Insert statement whith unknown number of values extracted from a string

I have a stored procedure in a sql server 2008 db. This stored procedure takes a parameter that is a list of max 5 comma separated integer values. This string is passed through a php sript and formatted like this: 01,02,03,14,15 These values should go in this table: Id | Type id ------------- 1 | 1 1 | 2 1 | 3 1 | 14 1 | 15 ...whe...

Why is my Navigation Properties empty in Entity Framework 4?

The code: public ChatMessage[] GetAllMessages(int chatRoomId) { using (ChatModelContainer context = new ChatModelContainer(CS)) { //var temp = context.ChatMessages.ToArray(); ChatRoom cr = context.ChatRooms.FirstOrDefault(c => c.Id == chatRoomId); if (cr == null) return null; return cr.ChatMessages.ToArray(); } } ...

C# RegEx.Matches doesn't return all submatches inside expression unlike RegEx.Replace

Hi guys, Could you help me to understand what is wrong. I have usual SQL query : var SQL = "SELECT [Extent1].[RouteID] AS [RouteID] FROM [RoutesEntities].[Routes] AS [Extent1]\r\n INNER JOIN [dbo].[Locales] AS [Extent2] ON [Extent2].[LocaleID] = [Extent1].[LocaleID]"; And i need to define location ...

Bug inserting multiple commands into a prepared statement

Hello, I'm working with Zend and postgres database, and I want get a result from a sql query that has inside more than one command. What I exactly want is create a table with some data and then ask for these data in a select query all in the same statement. but when it is executed, I got this bug: ERROR: cannot insert multiple command...

2 identfical sql queries w' diff params - only one requires temp table

The only difference in these sql queries is the record_id param (it's how I page through entire result set). The tables are myisam. The first query performs well and the second is terribly slow. Any idea why this would be? This query works fine explain select r.record_id, r.oai_datestamp, r.format_id, r.status, x.xml, max(u.date_u...