query

SimpleDB - how to select where ANY attribute matches a given string?

I am designing the layout and usage of an Amazon SimpleDB application. The docs for simpleDB give several example queries: Here is one: ref: http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1231 select * from mydomain where Title = 'The Right Stuff' I would like to use something like: select * from mydomain where * ...

Help searching MYSQL database with a JOIN - possible self JOIN ?

In a View i have a table of users combining data from multiple database tables. The important tables are Users and Invitations. Im performing a join LEFT JOIN invitations ON (users.id = invitations.invitee_id) which gives me access to users.invitee_id, but i also have dynamic search parameters in my query and i cant search for an invi...

Get mysql result and count specific field

I have database result like this ID | NAME | TYPE -------------------- 1 | baseball | 1 2 | kickball | 1 3 | football | 1 4 | soccer | 2 How do I do a select * so get all results but also get a total count of type = 2 in the results? Any help appreciated. ...

what can you query using the ManagementEventWatcher class

Hi, have been playing with the ManagementEventWatcher class and am curious what system events and objects you can select * from .. Is there a published list somewhere? ...

MySQL query problem with Bool

I have a problem with the following MySQL query: SELECT * FROM TPDSessions WHERE TPDS_Morning = 0 AND TPDD_Id = 1 AND TPDS_Chair1_idPerson = 16785 OR TPDS_Chair2_idPerson = 16785 The row returned has TPDS_Morning with a value of 1 in it, and I don't get why. This is the table structure: CREATE TABLE `TPDSessions` ( `TPDS_Id` int(...

MS Access & Excel: Turning a query with dynamic parameters into something useful

I got stuck in the problem beneath, because I don´t use Access or Excel much and I have some basic programming language. So here's the deal: I just made a fairly simple database in MS Access (2007) with a nice query to retrieve data, depending on which parameters you pass. In Excel (2007), I have this big 'template' which basically has...

Search query, 'order by' priority

I need implement simple search in small content table: id, name, description, content. Results must be order by priorities name description content it's mean that if searched word was found in description field, it will be shown only after all rows that have dog in name field What I did: I tried create temp table with structure lik...

In which sequence are queries and sub-queries executed by the SQL engine?

Hello I made a SQL test and dubious/curious about one question: In which sequence are queries and sub-queries executed by the SQL engine? the answers was primary query -> sub query -> sub sub query and so on sub sub query -> sub query -> prime query the whole query is interpreted at one time There is no fixed sequence of interpretati...

employee database with varing salary over time.

Hello, I have the following tables: PROJECTS - project_id, name EMPLOYEES - employee_id, name SALARY - employee_id, date, per_hour HOURS - log_id, project_id, employee_id, date, num_hours I need to query how much a project is costing. Problem is that Salary can vary. For example, a person can get a raise. The SALARY table logs the...

MySQL query running fine on v4.1.22 but not working on v5.x

I have an application that executes the following MySQL query: SELECT 402 AS user_id, p.id AS perm_id, p.name AS perm_name, lc.business_division_id, bd.name AS bd_name, bd.current_cycle, bd.current_moon, lc.name AS cycle_name, ...

Random MySQL row while avoiding holes

I have a big MySQL users table and need to get six random rows from it (I'm using PHP). The table has an index column that is auto incremented. The only problem is that some rows are marked as inactive, because some users have disabled their accounts or whatever. That means I can't just count the rows and then grab a random number from t...

Optimize SQL query

I'm trying to optimize this slow query (>2s) SELECT COUNT(*) FROM crmentity c, mdcalls_trans_activity_update mtu, mdcalls_trans mt WHERE (mtu.dept = 'GUN' OR mtu.dept = 'gun') AND mtu.trans_code = mt.trans_code AND mt.activityid = c.crmid AND MONTH(mtu.ts) = 2 AND YEAR(mtu.ts) = YEAR(NOW()) AND c.deleted =...

SQL Stored Procedure Problem due to the Lack of SP Performance

The main problem is that in my sp there are different objects and logic that may cause lack of performance. The things that I see on my SP and the tables that are in use in the SP 1- Temp tables such as shown below; (2 Temp Tables) CREATE TABLE #TEMP_TABLE( AB INT NOT NULL, AC INT NOT NULL, AD INT NOT NULL, AF INT NULL, AG IN...

Optimizing A Small Table Of Data For The Best Search (Querry) Speed

I have a table with 4 colums and N rows. At the beginning N will be around 1000 and will have tendency to grow up to 3000. 1st: string unique 2nd: int with N/5 unique values 3rd: int with 5 unique values 4th: data value The objective is to get to the value of the 4th column with different queries, ex: "get the value, where the 1st co...

Problem combining result of two different queries into one

I have two tables (TableA and TableB). create table TableA (A int null) create table TableB (B int null) insert into TableA (A) values (1) insert into TableB (B) values (2) I cant join them together but still I would like to show the result from them as one row. Now I can make select like this: select (select A from tableA) as...

Problem with mysql query

How can I optimize this mysql query: SELECT * FROM messages WHERE toid='".$mid."' AND fromid='".$fid."' OR (toid='".$fid."' AND fromid='".$mid."') AND subject != 'something' order by id ASC LIMIT 0,5 I need to get messages between users in one page. This query id taking to much time and server resources. Can it be done in...

Help With The Syntax Of This SQL QUERY

Hi, I'm inexperienced with SQL and I'm not sure how to form this query correctly. Select comment.text, (COUNT(parent.id)-1) AS depth FROM comments AS comment, comments AS parent WHERE comment.lft BETWEEN parent.lft ...

Need help on a JOIN query that almost works

I have four tables. posts | id | title | +---------+-----------+ | 1 | hello | | 2 | goodbye | +---------+-----------+ posts_tags | tag_id | post_id | +---------+-----------+ | 1 | 1 | | 2 | 1 | | 2 | 2 | +---------+-----------+ comments | id | post_id | c...

Select groups. Case ForRun ?

here is a structure :-/ So I need to select ID and Names from CfgListGroupParIzm for CfgIzmeritel using Type and where ForRun - False it's SELECT A.ID_ListGroupParIzm, A.Name FROM CfgListGroupParIzm A, CfgIzmeritel B WHERE A.ID_TypeIzmerit = B.ID_TypeIzmerit AND B.ID_Izmerit=@ID_Izmerit AND A.ForRun=0 AND ID and NamePoint(from Cfg...

Mysql column's row starts with value of another row

Hello all, I have a table like below: MyTable -------- A B C A,B,C are columns and MyTable is the table name and i want run a mysql query like: SELECT MT1.A, MT2.A, MT2.B FROM MyTable MT1, MyTable MT2 WHERE MT1.B<>MT2.B and MT2.B like "MT1.B%" and MT2.status=0; As you see from the query above i have a table and i wa...