sql

mysql select data from multiple rows

I have a table id, name, keyword 1 bob guy 2 bob developer 3 mary girl 4 joe guy Q1 : What would be the sql to get back the row (bob) containing both keywords 'guy' AND 'developer'? Intuitively, I thought it'd be SELECT * FROM TABLE WHERE keyword = 'guy' AND keyword = 'developer' Q2: But I suppose the first cond...

Join SQL Query Problem?

First Select Statement: SELECT dbo.FG_FILLIN.PartNumber, dbo.DropshipPackinglist.Shiplist_Qty, dbo.DropshipPackinglist.Quantity FROM dbo.FG_FILLIN INNER JOIN dbo.DropshipPackinglist ON dbo.FG_FILLIN.PartNumber = dbo.DropshipPackinglist.PartNumber WHERE (dbo.FG_FILLIN.Batch = 'CIP_HK_6') GROUP BY dbo.FG_FILLIN.Batch, d...

Make this report in one SQL in C#

EDIT: the database is Access 2007 Hi, I'm new here and I need some help: I have three tables: technicians (Id, tech_name, is_active) type_services (Id, serv_name, is_active) services (Id, date_time, prod_name, quantity, serv_type, tech_name, is_active) I have to make a report that contain: Number of services per tech (SUM(quantit...

Only display a specific category from a database (PHP/SQL)

From a dropdown menu a user can choose: view all, athletic, dress, or sandals. I am creating a function that if the user chooses athletic--only the Product Type 'Athletic', only athletic items from the database will be shown. Right now, because how my code is written, if the user selects 'Athletic' they will see athletic items, but also...

Mysql error 1111 in one version of query and error 1054 in another

I have two tables: books: [isbn, book_title, publisher, ...] inventory: [isbn, date, num_changed] I want to return book titles for those which are on stock. I tried a join (query 1) and got 1054 error, then I substituted the reference with the literal value and now I get 1111 error. query 1: SELECT `books`.`isbn`, `books`.`book_t...

Mysql - find a table in all database

Is there any command that I can locate a certain table from all databases? Since I forgot where the table is. Thanks. ...

error code 1005 error number 121 on 3 tables what am I doing wrong?

code: SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL'; CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ; -- Table mydb.SEX CREATE TABLE IF NOT EXISTS `my...

iterate an Ilist and insert to table

I've an IList with 5 items. I need to insert these, looping one by one, from the list to a SQL Server table using ado.net. I am using IReader(enterprise library) How can I do this? ...

[SQL] select row if the "value" % 2 = 1. MOD()

There is a column in options that hold an integer. I want to select the row only if that value % 2 = 1. I know this can be done in 2 queries but is it possible to do it in 1? ...

get RSS where there is none

Sorry for the long title and perhaps confusing half good now as we come. I'm asking advice or guidance on how I can get an RSS feed from a page that does not have RSS enabled by default. But that is not the problem itself. The problem is when on that page I am asked to enter a username and password. Well so otherwise would be the thing....

SQL check adjacent rows for sequence

I have a table with an id column (unique, primary), a name (not unique--in fact, most likely repeated), and a flag column which has values 0, 1, or 2. Let's say I reorder the table using the command SELECT id, name, flag ORDER BY name, id I want to produce using SQL a list of names where, when the rows in the reordering are read downw...

How to group by week specifying end of week day?

I need to run a report grouped by week. This could be done by using group by week(date) but the client wants to set the day of the week that marks the end of week. So it can be Tuesday, Wednesday etc. How can I work this into a group by query? The datetime column type is unix timestamp. ...

SQL script for incrementing dates

Hi, I am not sure how to make an automaticed script that incrments all dates in a database. I was asked if the date is Friday, the script needs to increment the next business date to Monday, so I will need some logic in the script. This can be easily done in C# or any other programming language. But, I was required that the script must ...

Display Album with Photos (PHP)

To start off, this really isn't CodeIgniter specific. I'm having trouble grasping an idea, so anyone that knows PHP/SQL (or whatever my problem is) can jump in. I have 2 tables, 'Photo' and 'Album'. Album columns : ID TITLE USER_ID CREATED MODIFIED Photo columns : ID ALBUM_ID TITLE LOC CREATED MODIFIED I'm using the query ...

Difference between implicit and explicit cursors in Oracle

I want to know the difference between these two statements. Is one 'better' than the other ? DECLARE myvar varchar2(50); BEGIN SELECT fieldone into myvar FROM tbl_one WHERE id = 1; END; AND DECLARE CURSOR L1 IS SELECT fieldone FROM tbl_one WHERE id = 1; BEGIN OPEN L1; FETCH L1 INTO myvar; CLOSE L1; END; ...

Is creating a view of multiple joining table faster then gettin that data directly using the join in a query?

Following is the query which is hit every table has over 100,000 records. SELECT b.login as userEmail, imgateway_instance_id as img, u.id as userId FROM buddy b INNER JOIN `user` u ON b.username = u.login INNER JOIN bot_to_buddy btb ON b.id = btb.buddy_id INNER JOIN bot ON btb.bot_id = bot.id WHERE u.id IN 14242 ...

SQL Server Table Structure, StartDate and EndDate

hi, I have a Tariffs table for international dialing Codes with StartDate and EndDate I'm using ASP.net Application to import excel offers to this table , Each offer contain about 10000 row, so it is a large table (about 3 millions row) what is the faster scenario in SQL Server 2008 to create a stored-procedure or trigger to change the...

SQL querying over multiple tables

I don't have much experience in SQL so I think this is not a dumb question. I have 2 tables like this. A .. G are the members of a hierarchy. Now my requirement is as follows. I need to filter out the members which has status = 0 from Members table. But, If the selected set contains children which has a parent with st...

UPDATE table from another table with case statement

Hi there! I'm currently having a problem. I need to update Table A from Table B based on this condition: If one record in Table A is null (ex. name) then update that record from Table B Here's my error driven script which I thought from my head. This is what I wanted to happen. UPDATE TableA SET NAME = ( CA...

Escaping command parameters passed to xp_cmdshell to dtexec

I am calling an SSIS package remotely using a stored procedure and a call to xp_cmdshell: declare @cmd varchar(5000) set @cmd = '"C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\dtexec.exe" /Rep E /Sql Package /SET \Package.Variables[User::ImportFileName].Value;c:\foo.xlsx' print @cmd exec xp_cmdshell @cmd This works fine, ho...