sql

Adding where clause to this SQL statement

Hi, I asked a question earlier this week and i got this statement as the answer: select published, count(*) nbr from table1 group by published order by nbr desc limit 1 I now want to know how it is possible to add a where clause in to the statement so that i can limit the results i get to the different types of publications. My tabl...

SQL query for displaying product sales.

I have sales table which consists, ItemSize, GroupName, Quantity, ProductID, etc... Now I want to display sales according to following format GroupName ItemSize Quantity ItemSize Quantity means BEER 350ml 500 650ml 1000 How I can achieve this in SQL SERVER 2005 EXPRESS (T-SQL)? Thanks UPDATED: its my sales table...

Whether to use SQL , XML/JSON ?

After doing my exercise in school, I use Sqlite to store my data. But there's XML / JSON [ I haven't tried yet, but I prefer JSON because its' simplicity ], they're used to store data too. And they seems popular, there's JSON for C#,C++,py .... I wonder when to use these ones ? And I'm happy to hear about theirs performance too, I care...

Cannot use Max with Count in SQL*Plus

this is my sql statement i get this error. but when i use only Max to single and without displaying other results it works. can someone help me SELECT cat.CategoryName,sb.SubCategoryName,MAX((COUNT(bs.BookID))) FROM Category cat,SubCategory sb, Book_Subcategory bs WHERE cat.CategoryID = sb.CategoryID AND sb.SubCategoryID = bs.SubCat...

SQL - how to select all related rows with external (?) conditions

Hi. I have three tables: player [id, name] attribute [id, name] player_attribute [id, player_id, attribute_id, value] each player can have different attributes, some of them don't have any. Now I need to search for players with certain attributes, e.g. all players that have number 11, and their first name is John. At this moment I al...

limit results on SQL request

Hey Guys, I'm wonder is it possible to limit the result of a SQL request? e.g only return up to 50 rows from SELECT * FROM <table> thanks. ...

Table name and table field on SqlParameter C#?

Hello. I would like to know how to pass the table name and a table field name via SqlCommand on C#. Tryied to do it the way it's done by setting the SqlCommand with the @ symbol but didn't work. Any ideas?? ...

SQL Server 2008 Version Problem.

Possible Duplicate: Restore Problem SQL Server Version? I have recently upgraded to SQL Server 2008 express from SQL Server 2005 express. But when I tried to run following command on SQL Server 2008 Query window Select @@Version I am getting following output: Microsoft SQL Server 2005 - 9.00.4053.00 (Intel X86) May 2...

Order of locks in query (postgresql)

Database has table X and tables An, Bn, Cn, Dn that inherits from X. Process 1 queries periodically data from X. Process 2 updates data in child tables. For example, to update tables An and Bn it creates new tables Am and Bm, loads data into them, locks in access exclusive An, Bn, drops An and Bn and alters Am and Bm to inherit X. The...

is this function true PL/SQL ?

Hello, is it used in the correct form in PL/SQL ? SELECT ename ,hiredate , TO_CHAR(TRUNC(ADD_MONTHS(hiredate,6),'MONTH'),'Le DD MONTH YYYY') AS "Révision" FROM emp thx ...

Selecting large amount of rows from database table with MySQL

I have a table with attributes like this: likes(id, message, ip, time) id is the primary key and is auto-incrementing. Whet I want to do is select 30 rows from this table based on an id that I provide. I can build a random array of all IDs I want to grab from the table, now I just need to go about doing that. My usual SQL query would...

Count the number of days between today & the hiredate in Oracle SQL?

Hello, how can i count the number of days between (sysdate) & a column called hiredate in PL/SQL. Thanks. ...

Starting MySQL Routines and Scripting

I have been using MySQL for a while, but only with basic queries and some joins. I want to start using Stored Procedures but I am having trouble finding a good resource to help me with what I want to know. The main thing I want to know is how to check the value of any field in the entire database before returning anything. For example: ...

error 3075 when running SQL in access 2007 vba

I wonder why I can't execute this SQL query in access 2007 through VBA, which can be executed when i create a query myself: Private Sub SQL_Click() Dim curDatabase As Database Dim RS_REPORT As Recordset Set curDatabase = CurrentDb Set RS_REPORT = _ curDatabase.OpenRecordset("REPORT_CONTENT_ARCHIVE", dbOpenDynaset) strStatement = "SEL...

MySQL - How can this query be optimised?

The following query works, but its very slow for 10 records (2 seconds). The profiling says its creating a tmp table, but I'm not sure why. Basically, I'm joining the current user, to the acl groups, to get all groups they are in, then joining the groups to the companies, to get all companies they are in, then joining the companies to t...

Can entities in Entity Framework inherit from an entity that is not mapped to a table?

Hi, I am using Entity Framework POCO to generate some self-tracked data objects, and I exposing these objects from a WCF service interface. I have EntityA & EntityB, which both map to different tables in the database. I would like both EntityA and EntityB to inherit from a base 'Entity' class, so that I can implement a simple WCF serv...

Using MySql, can I sort a column but have 0 come last?

I want to sort by an column of ints ascending, but I want 0 to come last. Is there anyway to do this in MySql? ...

Replication related issue,

Replication related issue, I am explaining my architecture . I have created , its transactinal replication process 2 Publisher on table vendors script I have given below, A Distributor 2 Subscribers Data replication set up is like this as : Table VENDORS gets replicated from 2-publishers to 2-subcribers via-Distributor. Whil...

Run the array mutiple times

Hey i need help, right now my script connect to an api and send a sms, 1 number at a time, I want it to pull from a local sql db then repeat the response for each number in the db! `$data['post'] = array ( '_rnr_se' => $rnrse, 'phoneNumber' => '1234567890', 'text' => 'This is a test SMS!', 'id' => ''...

How to manipulate SQL Azure database through pure REST calls

I am an iPhone developer. For one of my clients I am supposed to access their database stored in SQL Azure. I know that there is an Objective C SDK. I have downloaded it and ran the NetFilx example successfully. But of course my client's account is password protected. Also as of now the Objective C SDK seems to provide only read support...