query

Displaying records up to a certain 'age' - MySQL query syntax?

Quite a simple question, but I haven't been able to find any useful resources to help with this. Basically, I want to query my SQL database table, of which one of the fields is of type 'date'. Currently, the webpage outputs the three most recent records dependent on this date field. Ideally, I want to display all records which are under...

Problem in Union Join For MySQL Query

hey guys i managed to select from a table that saves my latest posts but i need to have double condition in selection here is my code : $sql_query = "SELECT b.*,u.username AS MY_Sender FROM TABLE_users u,TABLE_blogs b Where b.reciever = '0' AND u.user_id = b.sender UNION SELECT b.*,u.username AS MY_reciever FROM TABLE_users u,TABL...

Column name with special characters

I have web service which returns a datatable with the following column name: Id@qb>type I am applying the following filter statement to this datatable: [Id@qb>type] IN (0, 1, 2, 3, 4) But whenever I use this column name in the filter statement it throws the following exception: Invalid column name 'Id@qb>type'. Thanks. ...

mySQL: Deleting with JOIN ?

Hi everybody, This problem is giving me a real headache. I have two tables in my database that solves sorting of categories with the help of a design called "Closure table". The first table is called categories, and the other one is named categoriesPaths. Categories is simply a language-based table: id | name ---------------- 0 | C...

SQL Server 2008 + expensive union all

Hi al, we have 5 tables over which we should query with user search input throughout a stored procedure. We do a union all of the similar data inside a view. Because of this the view can not be materialized. We are not able to change these 5 tables drastically (like creating a 6th table that contains the similar data of the 5 tables and...

Getting unique items from NSMutableArray

Hi Guys, I have a question about Objective-C today involving NSMutableArray. Coming from a .net/c# background I'm having some trouble working with these things. Let's say I have an object called "Song" My song has 3 properties: Title Artist Genre I have a NSMutableArray or NSArray wich holds all my Song objects. How would I go ab...

Rails association query

I am having trouble accessing the correct information in my rails model (which I believe to be correct) The schema for my tables are create_table :schools do |t| t.string :name t.timestamps end create_table :variables do |t| t.string :name t.string :category t.timestamps end create_table :data do |t| t.string...

How to echo out table rows from the db (php)

i want to echo out everything from a particular query. If echo $res I only get one of the strings. If I change the 2nd mysql_result argument I can get the 2nd, 2rd etc but what I want is all of them, echoed out one after the other. How can I turn a mysql result into something I can use? I tried: $query="SELECT * FROM MY_TABLE"; $res...

Will_paginate and geokit misbehavior (double query)

Hi all, I'm using will_paginate to paginate my geokit search results. The code works, however, when looking at the log it does double the geokit query when using the following will_paginate call: @posts = Post.paginate :page => params[:page], :per_page => 1, :origin => @search, :within => @miles, :include => :u...

How can I get a list of the most recent tags in a wordpress database?

I am not familiar with the wordpress schema at all and I need to get back a list, or array of the most recent tags from any post in the wordpress database. I just need the data available on the home page so I can then manipulate it. All the functions seem to be designed to work on a per-post basis. (Wordpress really makes me feel sorr...

Limit results from joined table to one row

Here is a simplified table structure: TABLE products ( product_id INT (primary key, auto_increment), category_id INT, product_title VARCHAR, etc ); TABLE product_photos ( product_photo_id (primary key, auto_increment), product_id INT, photo_href VARCHAR, photo_order INT ); A product can have multiple photos, the first product...

how to get last weeek dates from today to last 7 days date..

i have a table with column: Registereddate orgid 2010-06-05 10:16:00 1 2010-06-05 10:10:00 2 2010-06-04 22:31:00 3 ... . . ..... . . . i need to get only last weeek dates and orgid from today to last 7 days date.. ...

Retrieve every key of a column family in Cassandra

Hi all, I have found no way to translate a simple select like SELECT * FROM USER into Cassandra. Is it possible to simply retrieve all the keys in a ColumnFamily? The only one I have found is a select with a key range (get_range_slices). Is there a way to get the entire key list without the need to define a key range? Thanks Tobia Losc...

Solr match all aka *:* does not work

Don't know what I did wrong. I have two indices with identical documents in it. The local index was replicated from a master which responds correctly, so the same solrconfig.xml and schema.xml file. But if I query the index on my local machine with *:* I get 0 docs. (other queries on my local machine are working correct) I tried jetty an...

mySQL: Joining three tables - how?

Hi everybody, I have the following query in my application. It works well, but I need it to also contain the number of products that are associated with each manufacturer. The current query: SELECT * FROM (`manufacturers`) JOIN `languages` ON `manufacturers`.`lang` = `languages`.`id` ORDER BY `languages`.`id` asc, `id` asc My prod...

how can i query a table that got split to 2 smaller tables? Union? view ?

hello friends, I have a very big table (nearly 2,000,000 records) that got split to 2 smaller tables. one table contains only records from last week and the other contains all the rest (which is a lot...) now i got some Stored Procedures / Functions that used to query the big table before it got split. i still need them to query the u...

Friendfeed schemaless data in MYSQL

I read an article around schema-less database which sounds cool. (http://bret.appspot.com/entry/how-friendfeed-uses-mysql) But what isn't clear to me is how do they run search queries on this data? Since the data is in JSON format how do we look for it? ...

Need help optimizing this Django aggregate query

I have the following model class Plugin(models.Model): name = models.CharField(max_length=50) # more fields which represents a plugin that can be downloaded from my site. To track downloads, I have class Download(models.Model): plugin = models.ForiegnKey(Plugin) timestamp = models.DateTimeField(auto_now=True) So to ...

How To Query Many-to-Many Table (one table's values becomes column headers)

Given this table structure, I want to flatten out the many-to-many relationships and make the values in the Name field of one table into column headers and the quantities from the same table into column values. The current idea which will work is to put the values into a Dictionary (hashtable) and represent this data in code but im wond...

Ampersand in sqlite query

How to construct sqlite query containing ampersand in filter: SELECT id FROM mediainfo WHERE album="Betty & Kate"; I use sqlite C interface (sqlite3_bind_text() and ? marks while query building) but neither C query nor SQLite Administrator return any data ...