query

MYSQL WHERE-IN Subquery Runs Forever

I have a MySQL table. Let's call it Widgets. The Widget table has 3 fields: id, type_id, and name. I want, in one query, to get all the widgets that share a type_id with the Widget named 'doodad'. I've written 2 queries: Give me the type_id of the widget with the name 'doodad'. Give me all widgets with that type_id. This works. Each ...

syntax 2 tables with between datetimepicker

thanks about your attention i have 2 table (first table) salary - fingerprintid - employeename - salary (second table) personallog - fingerprintid - verifymode (active work) - datelog - timelog how to make syntax query, if i want to find data. from 2 table where fingerprintid.salary=fingerprintid.personallog and between datetimepicker...

Issue in date comparison in MySQL

I have MySQL with below settings Server version: 5.0.77 MySQL client version: 5.0.41 Protocol version: 10 MySQL charset: UTF-8 Unicode (utf8) MySQL connection collation: utf8_unicode_ci I am just doing a simple query and it returned wrong SELECT * FROM table1 WHERE mydate >= '2010-08-30' Today is 8/30 and I have 1 row with mydate is '2...

Field's value of native query in JPA

Dear members, How to get value of some fields in a native query (JPA)? For example I want to get name and age of customer table: Query q = em.createNativeQuery("SELECT name,age FROM customer WHERE id=..."); Note: I don't want to map results to entities. I just want to get the value of the field. Thanks ...

Finding unused columns

I'm working with a legacy database which due to poor management and design has had a wildgrowth of columns which never have been or are no longer beeing used. Is it possible to some how query for column usage? As in how often a column is beeing selected (either specifically or with *, or joined on)? Seems to me like this is something w...

query for ms access

hi.my query is "SELECT column_name, table_name FROM information_schema.columns" .but it execute true in sqlserver ,but it dosn't execute true in Ms Access.i want to get all colums and tables'name from specific database.thanks. ...

Mysql query with user-defined-function - why function was called twice?

I have a 1:1 relation between tables Entity and Contact (that corresponds to object 's inherirance). fn_match(id) is UDF which returns boolean and returns true if record matches some special criteria (additional queries inside function). That's a query: select * from Entity a inner join Contact b on a.id = b.id where fn_match(a.i) It ...

How to query domain without exposing it

Hi, I have a problem. I am building a query engine for the gui consumer. So I have an silverlight application that does not expose Domain entities but rather use DTO objects. On the UserInterace I only have DTO's not the domain entities, so I cant create query like this: Query.AddCriteria(new EqualsCriteria((Person p)=>p.Name, "John"); ...

query to select a specified number of rows

Hello, Imagine a simple query: SELECT name, lastname FROM people Let's imagine it returns 6 rows. What i need to do is to return a number of rows that ROWS Mod 4 would be equal to 0. So if the query would normally return 6 rows, it should return 2 more rows with NULL for name and lastname. It's easy to count the rows it would return ...

A general single sql query.

I have a table like this: id | roll_no | name --------------------- 1 | 111 | Naveed 2 | 222 | Adil 3 | 333 | Ali If I have data like this: $fields = array( "id" , "roll_no" ) and $values = array( "1,111", "2,222" ); It means I have to write a sql query to get records from table where (id != 1 and roll_no != 111) an...

Querying Wordpress thumbnails

Hi, I am trying to get the thumbnail meta data for the posts in my wordpress blog together with their category and some other data. The thumbnail data is serialized and I will unserialize it later. Here is the query I have: SELECT wpostmeta.meta_value AS url, wposts.post_content, wposts.post_title, wposts.post_status, wposts.p...

LINQ to Entities Update Query

I'm trying to do a simple update but I cannae for the life of me work out what I am doing wrong. I have the following code which currently is not working - I'm getting not all code paths return a value. public List<tblWeight> UpdateFeedback(string memberid, string locationid, int prikey, string feedback) { MyEntities updatefee...

SELECT * FROM table WHERE field IN (SELECT id FROM table ORDER BY field2)

Hi there. I have 4 tables: categories - id, position subcategories - id, categories_id, position sub_subcategories - id, subcategories_id, position product - id, sub_subcategories_id, prod_pos Now I'm doing tests to find out what's wrong with my query. So i want to select sub_subcategories, and to get someting like that: [[1,2,3,4,5...

Linq to Entity update Query Part II

Ok, got my query going, up and running but it doesn't appear that I have got it working correctly!! My query is as follows: MyEnt updatefeedback = new MyEnt(); tblWeight newfeedback = ( from weight in updatefeedback.tblWeights where weight.MemberId == memberid where weight.LocationId == locationid where weight.PriKey =...

Sql Server Displaying Items in specific order

I have a list of items ItemName Manufacturer TopSalesUnit Item1 A 100 Item2 A 80 Item3 A 60 Item4 B 70 Item5 B 50 Item6 B 30 Item7 C 10 Item8 C 05 I would like the re...

nhibernate query all objects implementing an interface

For example, if you have an Apple : IWhatever, and an Orange : IWhatever and you want to find both of them because they are IWhatevers, what do you need to do in NHibernate? Is it completely dependent on the HQL or criteria query, or is there something you must do in the mapping also? If there is a mapping requirement, can Fluent NHiber...

Rewrite query string in .htaccess

I'm trying to do a very simple rewrite of a query string and I'm having no luck at all. I need to go from http:// example dot com/?ACT=jquery to http:// example dot com/index.php?ACT=jquery This is the code that I've written in my .htaccess file and it throws me an internal server error. I'm really new at this whole mod rewrite b...

SQL change query to show orphans

Give the query: SELECT tblProducts.ID, tblProducts.views, tblProducts.productName, tblProducts.isForSale, tblProducts.isLimitedStock, tblProducts.stockCount, tblProducts.description, tblProducts.weightKG, tblProducts.basePrice, tblProducts.dateCreated, tblProductCats.catName, (SELECT COUNT(*) FROM tblProductPrices WHERE product...

in Postgresql how to speed up substring queries

I have a simple logs table with about 500,000 rows, table structure is TABLE logs ( id serial NOT NULL, username character varying(32), user_id integer, description text NOT NULL, "time" timestamp with time zone DEFAULT now(), referrer character varying(128), "type" character varying(25) ) The most common operation in t...

How to query a table, in sqlalchemy

I know how to query on a model now. Suppose there is a Question model: class Question(Base): __tablename__ = "questions" id=Column(...) user_id=Column(...) ... Now, I can do: question = Session.query(Question).filter_by(user_id=123).one() But, now, I have a table (not a model) questions: questions = Table('question...