sql

SQL query select data between two date fields

I am trying to select data from a table, using two date fields (startdate and enddate). With both date fields in the where clause no results are returned, with the startdate field taken out results are returned, what is going on? Can anyone help with this dilemna My code is: SELECT WPP.USERID, WPI.EMAIL, WPI.FI...

Having trouble with this simple SQL Select statement.

I have two tables, A and B. Both have the exact same columns. I need to select all the items in TableA that ARE NOT in TableB. This is intersection, right? How can I do this? ...

SQL Selecting rows that are in both tables.

How can I select rows that exist is two tables. The intersection I guess? Any help? ProductosA and ProductosB, they're both tables with the exact same number and type of columns. How can I select the things that are inside of both using a single select statement? ...

Dynamic Column name in MYSQL

Yesterday I screwed up by asking question which had dupe column name by accident. This caused interesting solutions. So I will ask same question here again, but this time I will directly mysql dump, so there are no confusion. CREATE TABLE `tbl1` ( `UserID` char(15) DEFAULT NULL, `col1` char(15) DEFAULT NULL, `col2` char(15) DEFAUL...

Run SQL query on a binary file?

My company has a legacy micro-simulation program that simulates a population and changes to that population over a period of years. For each year, the program produces a binary file with a record for each individual that holds their characteristics (e.g., age, maritial status, income ... about 20 fields). We currently have several ut...

SQL Injection, simplest solution.

I'm unsure how someone would break my SQL if I simply replace all incoming single quotes with double quotes. Can someone enlighten me for both Oracle and SQL Server examples? Thanks. string sql1 = "select * from users where user_id = '" + "O'Reily".Replace("'", "''").Replace("\", "") + "'"; ==> "select * from users where user_id = 'O...

Determine if a row for an fk exists in any one of 20 tables

I was trying to determine a better way than so many IF/THEN statements to determine if ONE OR MORE tables contain a ref to a forign key. I simply need to know (true/false) if a row exists in any one of 20 tables. All tables have the same fk field. I hope this makes sense, if not i'll try to explain further. ...

How to create a patition table in oracle10g

How to create a partition table in oracle10g? ...

How to get a total time?

Using VB6 and MS Access Table: ID Lunch_Intime, Lunch_Outtime 001 13:00:00 14:00:00 002 12:00:00 13:00:00 003 12:00:00 15:00:00 004 14:00:00 16:00:00 So on… Lunch_Intime, Lunch_Outtime column data type is text. I want to get a Total_Lunch_Time for the id. Tried Query: Select Lunch_Intime, Lunch_Outtime, Lunch_Ou...

How does Microsoft certification 70-432 help in career building re: SQL Server and who should go for it?

How does Microsoft certification 70-432 help in career building re: SQL Server and who should go for it? ...

Why only one record after union?

mysql> select count(id) total from applicants; +-------+ | total | +-------+ | 0 | +-------+ 1 row in set (0.00 sec) mysql> select count(id) total from jobs; +-------+ | total | +-------+ | 0 | +-------+ 1 row in set (0.00 sec) mysql> select count(id) total from applicants union select count(id) total from jobs; +-------+ | tot...

sql query to test my programming capabilities in diffrent way

i have one table and one column in this.there is 15 data(integer).i want to count positive numbers and negative numbers and also sum of total numbers in one query . can any one help me ......... ...

Sql query to alter table

I have two tables miusernames with columns where UserNamesID is the primary key for table miusernames.. UserNamesID UserName 1 senthil 2 robert and miemailids with columns where Emailid is the primary key for table miemailids .. Emailid UserNamesID 1 2 I forgot to create...

SQL Query to find ID's with as many hits as possible from an Array.

Hi everyone, English is not my native language so i'll try to explain as good as i can. I have a table with ID's in this table i also have account numbers. something like this: ID ACCOUNT 1 1000 1 1001 1 1002 2 1000 2 1001 3 1003 then i have an array (Posted from a form, like name="array[0]",name="array[1]",name="array[...

Why do reads block other reads in MyISAM?

I have one really long running read. It is a cronjob run once a day, but the whole DB gets locked down when it is running : mysql> show full processlist; +--------+------+-----------+------+---------+------+--------------+--------------------------------------------------------------------------------------------------------------------...

Equivalent of Excel’s NETWORKDAYS function with Jet ADO

Excel's NETWORKDAYS function returns the net working days between two dates. Is there a way of replicating this when connecting to a Jet database via ADO? ...

Joining with subqueries, counting and grouping.

Hello everyone, I have 3 tables, which are each 1:n. an entry in table1 has n entries in table2, and so on. lets call them cars, wheels, and screws for illustration. Screws can be clean(1) or rusty(2) I am joining them together, because I want to count 2 things. First, I want to have rows telling me how many good/bad screws per whee...

Database / PHP security question

Hello, We are developing a very simple first stage GUI for a company database. At the moment our time to deliver is rather limited. So we thought about using a simple SQL stored procedure and retrieve all data. The data the users are allowed to see is depending on security levels defined in the database and also in our Active Directory....

(Firebird) SQL: 100x constraints in WHERE clause makes query extremely slow

Hi, I'm using Firebird and created a table, called EVENTS. The columns are: id (INT) | name (VARCHAR) | category (INT) | website (VARCHAR) | lat (DOUBLE) | lon (DOUBLE) Now a user wants to search for events in a certain radius around him, but entered only two or three letters of his home city. So we've got - lets say - 200 possible c...

Select latest revision of each row in a table

I have table structures that include a composite primary key of id & revision where both are integers. I need a query that will return the latest revision of each row. If I understood this answer correctly then the following would have worked on an Oracle DB. SELECT Id, Title FROM ( SELECT Id, Revision, MAX(Revision) OVER (PARTITION BY...