sql

SQL Paramaters in FoxPro 2.6 DOS

In FoxPro 2.6 for MS-DOS is there a way to use a variable in a SELECT command? For example, how can I write the following query: SELECT * FROM DBFILE WHERE Ord_no = temp_no Given that temp_no is a previously defined variable. I tried using "&temp_no" but this does not appear to be the correct syntax. ...

Using load-collection for an element with a composite key

Hi, I have two mappings, one with 2 named queries. Everything maps fine to the objects when I execute 2 separate repository calls - one for each object. The mappings for this are below: <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Company.Application.Models" assembly="Company.Application.Models"> <class name="Pro...

Create Default Constraint in Oracle SQL

Coming from SQL Server, I am learning some Oracle syntax. This is my table DDL CREATE TABLE "CDR"."EXTDL_REPORTSETS" ( "ID" NUMBER(38,0) NOT NULL ENABLE, "SHORTNAME" NUMBER(38,0) NOT NULL ENABLE, "DESCRIPTION" NUMBER(38,0) NOT NULL ENABLE, "ASOFSTARTDATETIME" NUMBER(38,0) NOT NULL ENABLE, ...

How can I merge :conditions for my SQL query

Let's presume that I have two different conditions :conditions => ["base == ?", self.search_text] and :conditions => ["status = ?", "#{self.status}"] Is there any way to merge these conditions into one query? ...

What is @ in Sqlparameter objName = new Sqlparameter ("@jobfolder", SqlDbType.Text)

What is @ in Sqlparameter objName = new Sqlparameter ("@jobfolder", SqlDbType.Text) ...

Reset the row number count in SQLite3/MySQL

I am using SQLite3. I load a table with say 30 rows using integer as Primary ID and it auto-increments. Now I delete all the rows from the table and then, reload some new information onto the table. Problem is: the row count (my PrimaryID) now starts with 31. Is there any way that I can start loading new rows from the number 1 onwards?...

Three Entity Intersection Table "many-many-many"

I'm currently working on a data model design (which will be backed by an RDMS). It is based around 3 entities relating to benefits for a member of the organization. The entities are the Benefit, Membership Type, and Provider. I've created a standard many-to-many intersection table to relate two entities, but never 3. I'm wondering if any...

How to put SQL data in a chart in Silverlight

I was wondering if anyone knew where I could find some information on how to get some data from a SQL database into a ColumnSeries chart in Silverlight-4.0/C#-4.0. I have tried Googling this and I cannot find anything that describes this process at all. Is it just a matter of giving it a path or something in the "ItemSource" property? ...

How to filter out similar rows (equal on certain columns) based on other column data.

How would I select all rows distinct on Forename and Surname and where there's a duplicate select the one with the higher SomeDate, then Id if still duplicates e.g. For: | Id | Forename | Surname | SomeDate | ---------------------------------------- | 1 | Bill | Power | 2011-01-01 | | 2 | James | Joyce | 2011-02-01 | | ...

Multiple Havings not working

I have a database with the following schema: ID PositionId LeagueId 1 4 5 3 4 5 3 8 5 4 1 6 I have this sql query in Access: SELECT lp.PositionId FROM Leagues l INNER JOIN Lineups lp ON (l.LeagueID = lp.LeagueId) GROUP BY PositionId HAVING sum(iif(lp...

Leading underscore not showing up in CREATE FUNCTION?

I inherited a database application that includes several SQL functions. We recently migrated to another server, and while I thought the move had gone smoothly, I'm getting error reports from users when they call a handful of functions. The functions were there, and looked correct, but eventually I noticed that there is a method paramet...

mysql query for transposing data

I need to transform the values in my column into different columns. Example data with me currently: id dtime std_time ifInOctets ----------------------------------------------------- 4 1279027201 13:20:01 1.34E+08 1 1279027201 13:20:01 34562 2 1279027201 13:20:01 9.72E+07 4 1279027201 13...

Advanced SQL books - tutorials

Hi My situation is i know the basics of SQL and am a little rusty on stuff to do with joins etc. Id like a book which covers relational databases(info about them etc), understanding normalisation, set theory and then more advanced concepts such as stored procedures, cursors and so on. Tutorials, books, anything is good! Obviously if t...

How to find the shortest distance/ travel time between two airports?

The problem was created by me, discussed with my co-workers and no one seem to have an idea. Thus, thought, I can ask the experts here. I've the following table FlightInfo and the fields are Start Destination Flight_Duration The goal is to find out, the shortest flight between two cities. The challenge is not all cities have di...

What is the purpose of Order By 1 in SQL select statement?

I'm reading through some old code at work, and have noticed that there are several views with an order by 1 clause. What does this accomplish? Example: Create view v_payment_summary AS SELECT A.PAYMENT_DATE, (SELECT SUM(paymentamount) FROM payment B WHERE = PAYMENT_DATE = B.PAYMENT_DATE and SOME C...

LEFT JOIN of a string

On part of my site, users enter multiple search terms. Each of these search terms may return 0 rows, or return several. I perform a UNION on all the searches and get the rows. Thing are much easier for me if I can get all the search terms in the response, regardless of whether they return any rows. Is there a way to essentially LEFT ...

Why is SQL server not using my index? (Filtering over joined indexed views)

I have two indexed views, v_First and v_Second. These views work great when I have a WHERE clause that filters only based on one of these views, however as soon as I have filter criteria based on both views I get two clustered index scans and poor performance as a result. My query is: SELECT * FROM dbo.v_First (NOEXPAND) JOIN dbo.v_Se...

Getting MySQL Schemas for All Tables

I want to download/backup the schema of an entire MySQL database. Is there a way to easily do this? I haven't had much luck using a wildcard, but that could be an error on my part. ...

Is there a way in MySQL to choose an order for the beginning and end of rows returned?

Look at this simple query SELECT id FROM users Now, say I wanted to have users with ids ordered 4, 5, 7, 8, then I don't care about the middle, and finally I want the last ones to be 55, 56, 58. So the returned rows would be something like this (\n a new row) 4 // explicitly chose these as the start rows 5 // " " 7 // " " 8 // "...

Can you explain this SQL injection?

The website i worked was recently attempted to be hacked by the following SQL injection script boys' and 3=8 union select 1, concat(0x232425,ifnull(`table_name`,0x30),char(9),ifnull(`table_rows`,0x30), char(9),0x252423), 3,4,5,6,7,8,9 from `information_schema`.`tables` where table_schema=0x62646B3032 limit 44,1 -- And '8'='8 Thi...