Jump to content

GeoffOs

Members
  • Posts

    24
  • Joined

  • Last visited

About GeoffOs

  • Birthday 01/17/1973

Contact Methods

  • Website URL
    http://www.osbaldestin.net/

Profile Information

  • Gender
    Not Telling
  • Location
    Cheshire, England

GeoffOs's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Because your grouping clause only specifies firstname then duplicates will be removed from the results where the firstname matches. I would have thought you would not need group by, unless you specify all the fields. The group by clause is explained http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html Are you expecting duplicates across all the name fields?
  2. Try: SELECT convert(varchar(20), text_date_updated, 20), convert(varchar(20), text_date_created, 20) FROM table
  3. Sounds good but I think: SELECT TheBlogTable.BlogId, TheBlogTable.BlogPost FROM TheBlogTable INNER JOIN TheTagTable on TheBlogTable.BlogId = TheTagTable.BlogId WHERE TheTagTable.TagText = "TagToCheckFor" I am not a big fan of sub queries, you cannot easily predict the performance......
  4. What about "SELECT ads.*, ad_maincat.maincat_name, ad_subcat1.subcat1_name, ad_subcat2.subcat2_name FROM ads INNER JOIN ad_maincat ON ads.maincat_id = ad_maincat.maincat_id INNER JOIN ad_subcat1 ON ads.subcat1_id = ad_subcat1.subcat1_id INNER JOIN ad_subcat2 ON ads.subcat2_id = ad_subcat2.subcat2_id WHERE ad_id = $_GET[ad_id] AND approved='Y' ORDER BY submitted DESC"; Though this expects to always have a main_cat, subcat1 and subcat2. If these are not always present then switch the join to be a LEFT OUTER JOIN so that the ads record is always returned irrespective of the existing of if the categories have been assigned. Though you should always check the $_GET variable is what you expect before putting it into a query.. Also have you read http://www.phpfreaks.com/tutorial/data-joins-unions
  5. That would be fine for showing the post, but what about listing all (paged) posts with a specific tag?
  6. but this would be inefficient if you have more than one tag per post. A one to many relationship with a Tags table would be much better and allow as many tags against a post as you wanted.
  7. If this was SQL Server something like: select count(ItemId), count(ItemId) as 'FailCount' FROM TestResults a inner join TestResults b on a.ItemId = b.ItemId and a.TestID = b.TestId WHERE TestFail = TRUE group by ItemId, TestId having count(ItemId) >= 3 Would be more efficient. I am not sure if the above would work in access. Though if you remove the bits that don't help the results in your existing query it should work a bit quicker: SELECT count(ItemId) from TestResults a where ResultId IN ( SELECT Top 3 ResultID from TestResults b Where a.ItemId = b.ItemId AND a.TestID = b.TestId ORDER BY TestDate DESC ) AND TestFail = true ) group by ItemId, TestId having COUNT(ItemId) >= 3
  8. I think your error is in this bit WHEN ISDATE (T1.[DocDate]) <> 1 THEN COALESCE (CAST (T1.[DocDate] as datetime),'NOT') You have already determined that T1.[DocDate] is null (or at least not a date) so you need to do this: WHEN ISDATE (T1.[DocDate]) <> 1 THEN COALESCE (T1.[DocDate],'NOT') Or Even WHEN ISDATE (T1.[DocDate]) <> 1 THEN 'NOT')
  9. try wrapping your date field with the following: select convert(varchar(50), getdate() , 20) For me this produces: 2009-04-22 12:24:23
  10. Why not calculate the $_SESSION bit before into a different variable: [code] if ($_SESSION['e_commerce_check'] == 'yes') { $check = ($_SESSION['turnaround_time+e-com']); } else { $check = ($_SESSION['turnaround_time']); } $message = " Order Number : ".$_SESSION['order_no']." Order Date : ".date("F jS, Y")." Development time guaranteed : ".$check." Days Name : ".$_SESSION['name']." Address : ".$_SESSION['address1'].";[/code] Or have I not understood the question?
  11. It would be handy to be able to view un-answered posts, that way, we attempt to answer them. Way back when I first created my account this was possible, but now seems to have disappeared.
  12. Have you installed SQL Server SP3a this fixes this issue on pre SP 2 versions of SQL Server on Windows XP / 2003
  13. Where is the SQL Server Located? Can you use extended stored Procedures. If so you could use a stored proc to send an email. Have a look here: [url=http://support.microsoft.com/kb/312839/en-us]http://support.microsoft.com/kb/312839/en-us[/url] Or you could configure SQL Mail, though this requires a MAPI profile from memory.
  14. You can use the group by clause. So your SQL would look something like this: [code] $query = "select * from ingredients, production, recipes, recipeMakeup where production.productionDate = '$today'"; $query.= "AND recipes.recipeID = recipeMakeup.recipeID"; $query.= "AND recipeMakeup.ingredientID = ingredients.ingredientID"; $query.= "AND production.recipeID = recipes.recipeID "; $query.= "GROUP BY ingredientName"; $query.= "ORDER BY ingredientName ASC;"; [/code] (I think)
  15. You could write two queries and union the results together [url=http://dev.mysql.com/doc/refman/5.0/en/union.html]http://dev.mysql.com/doc/refman/5.0/en/union.html[/url] For Example [code] select date from my table where date >= now() order by date desc UNION ALL select date from my table where date <= now() order by date asc [/code] Or something like that
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.