sql

how to get records from a file to use those records in a select statement?

Hi i have a file that consists of ids. my statement is select * from table_name where id in (?) ? in the statement should have ids.....but those ids are in file. help me please what i have to write in the place of ? symbol without creating table in database cant we done above thing? Thanks in advance ...

SQL as Control Source for Access Form field

Is there any way populate an Access Form's text feild's value using SQL? I have read that it is not possible to simply enter SQL as the Control Source. Is this true? thanks for any halp :) --edit-- I need to perform this query; SELECT tblCaseIssues.IssueDesc FROM tblCaseIssues INNER JOIN tblCaseNewHS_Issues ON tblCaseIssues.ID = tbl...

How to find a "gap" in running counter with SQL?

Hi, I'd like to find first "gap" in a counter column in SQL table. For example, if there are values 1,2,4 and 5 I'd like to find out 3. I can of course get the values in order and go through it manually but I'd like to know if there would be a way to do it in SQL. In addition, it should be quite standard SQL, working with different DB...

can we use files located in other server to create external tables?

create table ext_table_dat ( i Number, ) organization external ( type oracle_loader default directory ext_dir access parameters ( records delimited by newline fields terminated by ',' missing field values are null ) location ('$AI_SERIAL/file.dat') ) reject limit unlimited;...

How to select one's name day from first name and birth date?

Hey there. I would really appreciate your help in creating a query that would accomplish the following. The problem is with dynamically getting upcoming what we call "namedays" in europe. Nameday is a tradition in many countries in Europe and Latin America of celebrating on a particular day of the year associated with the one's given nam...

What fields can I update in oracle?

Is there a SQL script I can run in Oracle that will tell me which fields I have permission to Update? EDIT: I've tried these select * from USER_COL_PRIVS_RECD select * from DBA_COL_PRIVS select * from USER_COL_PRIVS_MADE select * from ALL_TAB_PRIVS_MADE select * from ALL_TAB_PRIVS_RECD and the only one that has results is the la...

How to measure performance of query in oracle

Hi all, I'm new to Oracle db. I have 2 queries which return the same result set. I want to measure the performance of each of them and choose the better one. How do I do that using Oracle SQL developer? I remember reading that certain tools provide stats. Any pointers on how to read these stats? Update: As suggested by Rob Van, I used ...

How do I query for a max value and return date found

I am trying to query for a maximium value from 5am to 5am the next morning. I would also like to have the start of query date in the results. here is what I have so far Select Max(Value) as RWQ22003DTDDS from History WHERE Datetime>='2009-08-21 05:00:00' AND Datetime<='2009-08-22 05:00:00' and Tagname ='RWQ22003DTDDS' I ...

ACCESS Jet SQL INT() Function -> SQL Server Function

Hey guys, I am converting an Access Jet-SQL query into T-SQL and I came upon the Int() function. Now, I would like to convert it into T-SQL, and this is what I have so far: --Works for Positive Select CONVERT(INT, 1.2) --Answer = 1 --Not the same as Access SELECT CONVERT(INT, -1.2) --Answer = -1 Now, according to this, I need it to...

Using joins correctly

I am looking for a tip on how to optimize this.... SELECT u.uid, u.username, u.nid, wd.pay FROM (users_data AS u LEFT JOIN winners_data wd ON u.nid = wd.nid AND u.uid = wd.uid) LEFT JOIN dp_node dn ON u.nid = dn.nid WHERE u.uid = ".$val." ...

Retrieving the last record in each group

There is a table "messages" that contains data as shown below: Id Name Other_Columns ------------------------- 1 A A_data_1 2 A A_data_2 3 A A_data_3 4 B B_data_1 5 B B_data_2 6 C C_data_1 If I run a query "select * from messages group by name", I will get the result as: 1 ...

PHP MVC & SQL minus Model

I've been reading several articles on MVC and had a few questions I was hoping someone could possibly assist me in answering. Firstly if MODEL is a representation of the data and a means in which to manipulate that data, then a Data Access Object (DAO) with a certain level of abstraction using a common interface should be sufficient for...

MySQL row count incorrect when reading a table's indexes from INFORMATION_SCHEMA.STATISTICS

I'm seeing some strange results when querying INFORMATION_SCHEMA.STATISTICS for index names. When I do "SELECT * ...", I see 2 indexes, but "SELECT COUNT(*) ..." it says count(*) is 0. Anyone know why? Is there a better way to get indexes on a table, ideally not MySQL-specific? Example: mysql> SELECT COUNT(*) FROM INFORMATION_SCHEMA.ST...

Basic SQL stuff... Left Join

I'm new to SQL. This didn't return any results..... SELECT media.id as mediaid, media.title as mediatitle, media.description as mediadescription, media.date as mediadate, media.duration, media.price as mediaprice, media.thumburl as thumburl, presenters.f_name as firstname, presenters.l_name as lastname, presenters.credential...

Slowly Changing Fact Table?

Background) I've gone through the process of building a fact table for our inventory data that will in theory act as a nightly snapshot of our warehouse. What is recorded is information such as quantity, weights, locations, statuses, etc. The data is very granular and in many cases not specifically related to a single entity (our source ...

Trouble with SQL CE and Linq

I'm trying to get my program to use a LocalDataCache. I'm using Linq. if (tempVehicle.VehicleFinancialInfo[0].askingPrice != null) { // do stuff } askingPrice is a (decimal?) because VehicleFinancialInfo is a linq entityset. The above if test works on SQL Express but it crashes the app in SQL Compact Edition. It gives the error "...

Query works ok in phpmyadmin but not with mysql_query php function

I have this sql query: SELECT DISTINCT r.uri uri FROM resource r INNER JOIN object o ON o.idResource = r.idResource WHERE r.type = 2 AND r.idResource IN ( SELECT DISTINCT r1.idResource FROM object o1 INNER JOIN resource r1 ON r1.idResource = o1.idResource INNER JOIN class c1 ON c1.idClass = o1.idClass INNER JOIN property p2 ON...

Emulating SQL LIKE in JavaScript

How can I emulate the SQL keyword LIKE in JavaScript. For those of you who don't know what LIKE is, it's a very simple regex which only supports the wildcards %, which matches 0 or more characters, and _ which matches exactly one character. However, it's not just possible to do something like var match = new RegEx(likeExpr.replace("%",...

how to select a row where one of several columns equals a certain value?

Say I have a table that includes column A, column B and column C. How do I write I query that selects all rows where either column A OR column B OR column C equals a certain value? Thanks. Update: I think forgot to mention my confusion. Say there is another column (column 1) and I need to select based on the following logic: ...where...

SQL in Rails - Chaining "AND"

Hi, I don't get why SQL does not like my query: @unreadmessages = Message.find(:all, :conditions => ["receiver_id = ? AND receiver_archived = ? AND read = ?", self.current_user, "No", "No"]) There is a different way to write this, but I want to keep my style consistent (this one avoids SQL injections, I gather.). Thanks for your inp...