Re: Query String



I need a query to firstly retrieve the latest 10 news articles by
date, where I have used ORDER BY and the date field 'timestamp' with
LIMIT. So far so good..

I have then indicated in the database whether each news article has an
image included, marked by the field 'image' and options 'Yes' and
'No'.

To prioritise the news articles to view those with images first, I
have used AND image IN ('Yes', 'No') but I get 'Error in query:
$query'.

You put that in the WHERE clause, not in the ORDER BY clause.
Since you don't have a WHERE clause, you put it in as
WHERE image in ('Yes', 'No')

I don't see where adding this does anything unless the `image` field
has values other than 'Yes' and 'No'.

$query = ("SELECT image, newsid, title, headline, timestamp FROM news
WHERE image IN ('Yes', 'No')
ORDER BY timestamp DESC LIMIT 10");
.



Relevant Pages

  • Re: Concurrency Help
    ... The timestamp column is changed whenever ANY data in the row is ... >> An UPDATE operation with a focused WHERE clause is an atomic operation. ... I want to know if a database, ... >>> 1 would overwrite client 2's changes to the db. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: year to date conversion
    ... timestamp) comparisons if the column is of DATE type. ... There is nothing wrong with the second statement but the syntax ... explain-result clearly shows that the DB-engine is using an index ... a file and execute them on the database. ...
    (comp.lang.java.programmer)
  • Re: Index corruption on table without key: what could be the reasons ?
    ... > we are running a SQL-Server Database which is about 30 GB large. ... > where we expect for every device and timestamp one row of data. ... > What could cause the index corruption? ... Uli, ...
    (comp.databases.ms-sqlserver)
  • Re: Want search on timestamp ! Any other alternative ??
    ... Is there any performance issues (database) involved making DATETIME a better choice? ... Let's say I use an Unsigned Int for the field "timestamp" in my database. ... You can do exactly the same query using datetime fields, and it is a native database format, so I suspect difference in performace here is negligable. ...
    (comp.lang.php)
  • Re: Index corruption on table without key: what could be the reasons ?
    ... > we are running a SQL-Server Database which is about 30 GB large. ... > be introduced when the application programmers have changed their ... > where we expect for every device and timestamp one row of data. ... > What could cause the index corruption? ...
    (comp.databases.ms-sqlserver)