query

How can I insert a post into wordpress and associate it with a category?

I have content from elsewhere that I would like to insert as a post in Wordpress and then associate with an existing category. It is pretty straightforward to insert a new post into the wp_posts table, but I can't seem to figure out how to construct a query to both insert a new post and at the same time associate the post with a categor...

Sql server DELETE and WITH clause

I need to build an SQL statement to delete from certain table the records that match another select statement. In Teradata we use delete from table1 where (col1, col2) in ( select col1,col2 from table2 ) While in SQL Server it's not allowed to have more than 1 column in the WHERE..IN clause. I thought I can use the WITH clause...

Lucene query syntax

Hi, I want to write a Lucene query which is the equivalent of the following SQL where age = 25 and name in ("tom", "dick", "harry") The best I've come up with so far is: (age:25 name:tom) OR (age:25 name:dick) OR (age:25 name:harry) Is there a more succinct way to write this? Thanks, Don ...

Help with sql server query

Hi I have this table: proj - nun - X aaa - 1 - 0 aaa - 2 - 0 bbb - 3 - 0 bbb - 4 - 0 bbb - 5 - 0 bbb - 6 - 0 ccc - 7 - 0 i need to get this proj - nun - X aaa - 1 - 1 aaa - 2 - 2 bbb - 3 - 1 bbb - 4 - 2 bbb - 5 - 3 bbb - 6 - 4 ccc - 7 - 1 how I can do it with sql query ? (sq...

MySQL - get elements from a link table but ONLY those elements

I have a problem selecting from a link table and filtering out superfluous results. Publications belong to packages by means of the package_publications table. For instance, I know the ids of my publications to be 11 and 47. I want to return a package that has ONLY those publications in it. Now if I do a join and do something like whe...

appending string in existing string in sqlite3 manager fro firefox?

hello i have i want to do something like this. i have 4 rows with unique id 1,2,3,4 all four rows contains some string like option1,option2,option3,option4 now i want to add "a ) " to the option1, "b ) " to the option2 and so on so is there a way i can do this with a query.currently i am adding these to a lots of rows manually ...

LIMIT on a condition in MySql

Hi all I am trying to get info from a table in this form : table_1 jobid(PK) projectid desc 1 1 whatever 2 1 . 3 1 . 4 2 . 5 2 . . . . . . . . . . What I am trying to get is a query wh...

How do I produce a time interval query in SQLite?

I have an events based table that I would like to produce a query, by minute for the number of events that were occuring. For example, I have an event table like: CREATE TABLE events ( session_id TEXT, event TEXT, time_stamp DATETIME ) Which I have transformed into the following type of table: CREATE TABLE ses...

Linq to xml error

Hello, i have a problem with my linq to xml query var q = (from f in xmlLang.Element("lang").Elements("page") where (string)f.Attribute("id") == "home" select f.Element(LangElement).Value.ToString()).Take(1).SingleOrDefault(); The xml looks like this, <lang> <page id="home"> <hello>Hello!</hello>...

Fetch MySql database from cocoa app - PHP bridging [Solved]

Hello to everybody, I'm trying to download a range of rows from my MySql database, through a cocoa app that I'm developing! To do all more easy, I use a php that receive an index from my app and send back all the rows up to that index. So, my cocoa code is: NSInteger index = 0; NSString *urlString = [NSString stringWithFormat:@"http://...

SQL Server 2005 Query Help

I have a table and I want to get the row before the last one. Eg KeyboardID KeyboardName 1 "DELL" 2 "HP" 3 "Viewsonic" 4 "Samsung" select max(keyboardid) from keyboard -> will get the Samsung My Question is how to get the Viewsonic Keyboard... ...

MS Access 2003 - Creating a Dashboard - Return Values to a form?

So this is something that I have never tried, but I think I want to create a Metrics Dashboard in my MS Access database. So I think the first question that I need to ask is how can I return a value to a form? If I ave aggregate queries that are top 10 total sales, how can I specify not only the query that I want the top result to come f...

php codeigniter assembling query results

My setup is as follows: Table 'data': 'title','body',...,'user_id',... Table 'users': 'user_id','some_val'... Basically I want to somehow join the tables 'data' and 'users' on the user_id field so that I can pull 'some_val' from the 'users' table. My problem is that not every user_id in the 'data' table has a corresponding entry in...

SQL: Selecting parents and their children

I'm sure this is a common query but I'm not certain how to phrase it best. I have two tables: Questions { Id, Text... } Answers { Id, QuestionId, Text...} I would like to retrieve a list of Questions and their Answers, so that the results can be displayed like this: Question A 1st answer to question A 2nd answer to question A 3rd...

How to write prepared statements for SQLite in iPhone

How to write prepared statements for SQLite in iPhone? Is it possible to do SQL Injection in iPhone apps that use sqlite db? ...

How to "order by" a column and "Include Column Name with query"?

Hi, I am trying to run a sql query in excel and I want to : 1. order the query result by my column "Stationname" 2. include the column names with the query Right now it is returning all the columns without the column name, and the end users do not know what it is. Could someone please help? I am stuck! Below is my current code: ...

Linq Query Using DataTable with Paging

I have a Linq query that I copy to a DataTable which is then used to populate a gridview. I am using a group by "key" and "count" which I evaluate in the aspx page for a master/detail gridview with a repeater. The problem that I am encountering is that the gridview datasource and bind to the datatable is not presenting me with any addi...

ODBC 5.1 Nothing appears in the database!

Hi, I'm working on VS2005 and have tried using MySQL's ODBC to connect to a database. The problem is that when I get to the part of choosing which tables to use, there are no tables and the only selectable thing is a View, which has no name and is null (of course something like this doesn't really exist in the DB). I tried adding a Table...

Do aggregate MySQL functions always return a single row?

I'm sorry if this is really basic, but: I feel at some point I didn't have this issue, and now I am, so either I was doing something totally different before or my syntax has skipped a step. I have, for example, a query that I need to return all rows with certain data along with another column that has the total of one of those columns...

hibernate sql query

hi, i have a strange problem with a hibernate sql query: The db relations are like follows: registration has one invoicerecipient registration has many attendees i have the persid of an invoicerecipient, so I should get in both following cases the associated registration, but only the second case works. Does anybody know why the firs...