query

How can I join 3 tables with mysql & php?

check out the page [url]http://www.mujak.com/test/test3.php[/url] It pulls the users Post,username,xbc/xlk tags etc which is perfect... BUT since I am pulling information from a MyBB bulletin board system, its quite different. When replying, people are are allowed to change the "Thread Subject" by simplying replying and changing it. I ...

How to add multiple OR in MySQL query

Example DB structure (download table) id | pid | title ---------------------------------------------------- 1 | 3,4,5 | Download 3, Download 4, Download 5 ---------------------------------------------------- 2 | 3 | Download 3 ---------------------------------------------------- Here is my code <?php $pid = explode(",...

How do i change query of MS Access 97 file using MS Access 2007

Hi guys, I am adding a small feature in a program that uses access 97 db. The change is to add a one single field in a table A. There is one query which selects certain fields from that table. Now I need to add the field in that query too. I have added the field using DDL SQL statment from query builder screen. But now I need to add t...

Insert Only: ActiveRecord or Queries?

All that I will do is insert records into the database. However, I would definitly like the database-independence that Ruby/ActiveRecord can offer me. What would be the reccommended choice? Using simple insert queries, and rewriting them, and also maintaining my own database class for things as batch insertions; Using the power of Act...

How to return all database rows with certain field value.

Hey, I have a database table called "projects" with the fields 'id', 'locationid', 'name' and 'year'. I query the database to retrieve all the values and store them in $data, before passing them into the relevant view. In what part of the website, I have created a timeline (made of list items generated with a foreach). In this timelin...

what is the correct SQL to get "most used query"

i have a table called Rides id car_id distance i have another table Cars id name i want to run a query that return the most drives per car (on cars that i have rid greater than once) so the results i am looking for are something like this (to be returned in descending order): Ford 10 BMW 8 Ferrari 5 Jeep 4 I have: sele...

long oracle query

Hi there, I've got really long and complicated query(Oracle 10g). It contains about ten select subqueries. The query works but it's too long. Should I somehow divide this query? I mean is there some standard how long/complicated could sql query be. The query works but it doesn't seem to me like the best solution. For example one subquery...

sql queries in code files

I am a little bit reluctant when it comes to mixing SQL queries with my code ... I tend to not like it aesthetically. I was wondering whether there's a better way of storing them, without having to mix them with the code. What I've found until now: Use an ORM and you don't have to worry about storing full SQL strings - this is not an o...

Oracle sql function question

How to display the details of employee whose name contains the same characters at the start and end position of their name? ...

I want to know if this query method is possible ?

I have this Query SELECT PaymentDetails_ID AS Pay_ID, Type, Description, Details, Due_Date, PaymentDetails_Cleared, Amount, Mode, (SELECT Bill_ID FROM Bill_Payment_Records WHERE (Payment_ID = Pay_ID)) AS Bill_No FROM Pa...

Is there a quick way to compare two equally formatted tables in SQL?

I would like to make an sql query to compare two tables with identical columns, both names and types. Each table has a unique key. I want the query to return any rows that contain unequal values. I know could do something like this select * from table_1, table_2 where table_1.key = table_2.key and ( table_1.col1 != table_2.col1 OR t...

SQL Code to Select to select unique column and match with row on another column.

Not even how to word this question: I have a table that looks like this: select * from tblServiceUsers ORDER By ServiceID 0 B88230BB-4943-4C10-AB0E-8ABB88A357A3 0 5653C943-7F9A-4746-B2A3-1160E9204A7E 0 08678EE7-49A7-4F63-BC39-CFCCE2C9AD65 1 B88230BB-4943-4C10-AB0E-8ABB88A357A3 1 5653C943-7F9A-4746-B2A3-1160E9204A7E 2 B8...

unable select unique values from a query

Hello, I want to select the name of a field on separate table, however I can only do this once. Cname1 will work , Cname2 will not. The problem is I would like a unique categoryChild name for m.categoryChildID2 but the only way I know how to reference this is with c.categoryChild BUT this is already in use with the m.categoryChildID1. ...

How to compare values within the same table in TSQL elegantly

I've got a settings table constructed with 'category' determining different products, 'varname' being the variable name, and 'info' being the value of the setting. so, for instance, select top 6 category, varname, info from settings_table where NODE_NAME='HTT-COMM-A' and section='Module Settings' and category in ('ProductA',...

Is it possible to set a timeout for an SQL query on Microsoft SQL server?

I've got a scenario when sometimes a user selects the right parameters and makes a query which takes several minutes or more to execute. I cannot prevent him to select such a combination of parameters (it's quite legal), so I'd like to set a timeout on the query. Note that I really want to stop the query execution itself and rollback an...

mysql,select query ,and or clause problem

i have a table named item with four attribute name,code,class,value now i want to group them in following way: group a: name='A',code=11,class='high',value between( (5300 and 5310),(7100 and 7200),(8210 and 8290)) group b: name='b',code=11,class='high',value between( (1300 and 1310),(2100 and 2200),(3210 and 3290)) how can i do it? ...

Specifying index in HQL queries

Is there a way to specify which index to use, in HQL, to retrieve values from a MySQL table that has an index defined? ...

Get next birthdays using Doctrine

There's any way to get the next birthdays using only DQL (Doctrine Query Language)? I solve the problem using the SQL function DAYOFYEAR but I think that's not correct because that only work on MySQL and if I have to migrate to MSSQL (for example) that doesn't work. Thanks in advanced. ...

Select distinct rows from MongoDB

How do you select distinct records in MongoDB? This is a pretty basic db functionality I believe but I can't seem to find this anywhere else. Suppose I have a table as follows -------------------------- | Name | Age | -------------------------- |John | 12 | |Ben | 14 | |Robert | 14 |...

MySQL Slow join - but not always and not on all tables

We're experiencing a performance issue with a MySQL database that's so weird we need another set of eyes to tell us whether we're going crazy or not. We've got 2 MySQL Certified Developers in the team, but all they can say is : "this is impossible". Anyway, here's the situation : we have a query that in theory should be reasonbly fast, ...