query

Access DB update one table with value from another

I'm trying to update all records in one table with the values found in another table. I've tried many versions of the same basic query and always get the same error message: Operation must use an updateable query. Any thoughts on why this query won't work in Access DB? UPDATE inventoryDetails as idet SET idet.itemDesc = ( ...

[Mysql] Fetch all news and all comments

Hi, I'm trying to code a query that gets all the news and all the comments for each news. My current query is : SELECT n.*, c.* AS comments FROM news n JOIN comments c ON (c.news_id = n.id) But when I fetch the query as an array it gives me a key by comment and I would like to have a key by news and all comments in a s...

Passing youtube video id from video feed to flash

I'm working on a flash web application (Actionscript 2.0) for my honours project but am having trouble embedding youtube videos. Basically the user selects symbols which queries the youtube api with certain tags depending on the symbols chosenand a random video is then picked from the first 30 videos. I have this working using the follow...

PHP Query from a FORM

So I have a form that I post to a page and in the form I'm posting certain variables that I build one of my queries with and then call them on my page. How can I post data and also build a query and display the answer on one call? Maybe I'm not wording it right and I'm learning this stuff, but I just don't know. Should I post to an in...

how to user year() and month() functions in NH Criteria API?

I need to use year() and month() functions in Criteria API to be able to express a business filter constrain. Expressions like cri.Add(Expression.Ge("year(Duration.DateFrom)", Year.Value)); cri.Add(Expression.Le("year(Duration.DateTo)", Year.Value)); obviously do not work - is there any solution how to achieve this? I know it's enti...

How to compare value of 2 fields in Django QuerySet?

I have a django model like this: class Player(models.Model): name = models.CharField() batting = models.IntegerField() bowling = models.IntegerField() What would be the Django QuerySet equivalent of the following SQL? SELECT * FROM player WHERE batting > bowling; ...

select rows in a one to many situation

Hi everybody! I think that I am stuck with this particular situation: Here are my tables: item_table: id | item 1 : A 2 : B 3 : C attr_table: attr | item_id 1 : 1 1 : 2 2 : 1 2 : 3 3 : 2 3 : 3 I would like to know if it is technically possible to retrieve any item which is associated with attr = 1 and 3. The answer shoul...

SQLite - how to get average value?

Hi, I have in my table a column that has values of type FLOAT. How can I get average value of all elements in this column? Thank you in advance. ...

Generate a Fire Register report

Hello, I am stuck figuring out a working SQL Query for the fallowing: I need to generate a Fire Register report (how many people are still inside the building) based on an Access database that records login/logout events along with some metadata. The Access DB looks like this: +----+---------------------+---------+---------+------+ | i...

MySQL - Optimize a Query and Find a rank based on column Sum

I have a high score database for a game that tracks every play in a variety of worlds. What I want to do is find out some statistics on the plays, and then find where each world "ranks" according to each other world (sorted by number of times played). So far I've got all my statistics working fine, however I've run into a problem findin...

how to write this query for this xml data in linq to xml?

hi guys, i've been reading through the linq to xml documentation in msdn and some other tutorials and yet i failed to find the right way to do this query as of now :( Basically, i want to loop through each student in the class, for each question, keep a counter of individual skill, i.e. for student 123, the tally should be 001.101.033.0...

How to count and limit record in a single query in MYSQL?

I am searching for records in a table as follows: SELECT Id, Name FROM my_table WHERE Name LIKE '%prashant%' LIMIT 0, 10; Now, I am adding LIMIT to maintain my paging. But when user searches for word 'prashant' then total records I have is 124 for 'prashant'. But as the limit applied to the query so it only fetches 10 records in my PH...

How to execute two mysql queries as one in PHP/MYSQL?

I have two queries, as following: SELECT SQL_CALC_FOUND_ROWS Id, Name FROM my_table WHERE Name LIKE '%prashant%' LIMIT 0, 10; SELECT FOUND_ROWS(); I want to execute both these queries in a single attempt. $result = mysql_query($query); But then tell me how I will handle each tables set separately. Actually in ASP.NET we uses datas...

Checking sequence with SQL query.

I have a table orders that keeps all order from all our stores. I wrote a query to check the sequence orders for each store. It looks like that. select WebStoreID, min(webordernumber), max(webordernumber), count(webordernumber) from orders where ordertype = 'WEB' group by WebStoreID I can check it all orders are present with this qu...

MySQL Advanced Query Brainteaser

I've been asked to create a financial report, which needs to give a total commission rate between two dates for several 'referrers'. That's the easy part. The difficult part is that the commission rate varies depending not only on the referrer but also on the type of referral and also on the number of referrals of that type that have be...

SQL Query Question: X has many Y. Get all X and get only the newest Y per X.

Suppose we have two tables. Post and Comment. Post has many Comments. Pretend they are somewhat filled so that the number of comments per post is varied. I want a query which will grab all posts but only the newest comment per post. I have been directed to joins and sub queries but I can't figure it out. Example Output: Post1: Comment...

Mysql: Getting Count of Comma Separated Values With Like

I decided to use favs (id's of users which marked that post as a favorite) as a comma separated list in a favs column which is also in messages table with sender,url,content etc.. But when i try to count those rows with a quey like: select count(id) from messages where favs like '%userid%' of course it gives wrong results because al...

sql query joins multiple tables - too slow (8 tables)

hi, i'm trying to join 8 tables into one in order to create index used by other application, my query is like : (my mysql skill's very amateur) SELECT t1_id, t2_name, t3_name, t4_name, t5_name, t6_name, t7_name, t8_name, t9_name FROM t1 LEFT JOIN t2 ON (t1_id = t2_id) LEFT JOIN t3 ON (t3_id = t1_id) LEFT JOIN t4 ON (t4...

What to use in creating a hand held database application

What program/programming language would be ideal for creating an Access like database on a Windows 5 CE hand held scanner? We have tried Visual CE but it is not really something we can work with. Ultimately we would love to build a system where we scan a bar code, select a user from a drop down list, select basic options of division, l...

Access db loop - for each record in one table create array of records in another table

Is it possible to create a nested looping query in Access DB that will update a third table? I have a master (header) table: ------------------------ masters ------------------------ num | modality | cost | ------------------------ 01 | thing | 23.00 | 02 | thing | 42.00 | 03 | thing | 56.00 | 04 | apple | 11.00 | 05 ...