The online racing simulator
:worried:

Oh well I'll have a better look when I can then... if no one else comes here and tell us what's wrong.
Okay, thanks. And if you wanted, I could post a sql document of all my tables, if it helps...
Probably, but I'd rather not do this at work.
That's for sure You can tell me when you want it. The site's server suddenly stopped working (free hosting), so I can't view my site, I can only test the queries in phpMyAdmin.
What about if you extend the WHERE clause with
OR number_of_layouts = 0

I'm heavily tangled up in C++ right now so my mind might mess up SQL a bit, but in my currently somewhat confused state that should return users with layouts and users without any, but not duplicates.
Quote from morpha :What about if you extend the WHERE clause with
OR number_of_layouts = 0

I'm heavily tangled up in C++ right now so my mind might mess up SQL a bit, but in my currently somewhat confused state that should return users with layouts and users without any, but not duplicates.

I don't know why but it says unknown column 'number_of_layouts', although I have set this name as the alias.
Quote from Flame CZE :I don't know why but it says unknown column 'number_of_layouts', although I have set this name as the alias.

Which MySQL version are you running? Try the COUNT() just to test the theory, then we can set about finding out why the alias doesn't work
Quote from morpha :Which MySQL version are you running? Try the COUNT() just to test the theory, then we can set about finding out why the alias doesn't work

The MySQL version is 5.0.81-community. What do you mean by testing the count()?

Edit: I don't want to spam it here much, if you want to, you can add me on MSN.

SELECT U.username, COUNT(L.user_id)
FROM users U, layouts L
WHERE U.id = L.user_id GROUP BY U.id

I'm assuming this is for a web application... you should consider an object-relational mapper so you don't have to write SQL.
Quote from tmehlinger :

SELECT U.username, COUNT(L.user_id)
FROM users U, layouts L
WHERE U.id = L.user_id GROUP BY U.id

I'm assuming this is for a web application... you should consider an object-relational mapper so you don't have to write SQL.

But I don't know anything about objects in PHP
Quote from tmehlinger :

SELECT U.username, COUNT(L.user_id)
FROM users U, layouts L
WHERE U.id = L.user_id GROUP BY U.id

I'm assuming this is for a web application... you should consider an object-relational mapper so you don't have to write SQL.

This would still only return users with at least one layout uploaded though, right? Because U.id would never be L.user_id if L does not contain the U.id. Hence my suggestion of ORing for COUNT(L.user_id) = 0.
Quote from Flame CZE :It returns me the same...
SELECT U.username, COUNT(L.user_id) AS number_of_layouts
FROM users U
LEFT JOIN layouts L ON U.id = L.user_id
WHERE U.id = L.user_id
GROUP BY U.id


To me this looks close but I think you need the keyword OUTER when doing the join. ie LEFT OUTER JOIN layouts L ON U.id = L.user_id. I'm pretty sure the default join type is inner, which will throw away all rows that don't match whereas outer won't. Also take out the WHERE clause as thats exactly what the join replaces
Thanks, it works now! Now I must wait for the server to run
Great.

@Stuff: thanks for pointing that up.
Quote from morpha :This would still only return users with at least one layout uploaded though, right? Because U.id would never be L.user_id if L does not contain the U.id. Hence my suggestion of ORing for COUNT(L.user_id) = 0.

Yeah, you're right. Silly mistake on my part. I whipped up some test tables and it worked, but I didn't consider the zero case.

Either way, he's got it working now so woooooo.
Quote from tmehlinger :Either way, he's got it working now so woooooo.

Well if both queries work, he should go for the better performer, which Stuff's solution probably is anyway
Yes, I will use the Stuff's one

And by the way, the "server problem" is probably just a feature, when if one IP reaches 2000 page views, it gets blocked for the rest of the day. I was working so hard, that the refresh count was higher than expected
-
(DarkTimes) DELETED by DarkTimes
Visual Studio 2010 is out today, including Visual C# 2010 Express Edition.

Of course, this also means that the .NET Framework 4.0 is out too, so everyone with a Windows system should download it post-haste. Contrary to popular belief, the .NET Framework client is actually a rather small download, normally just a few megabytes. You officially have no excuse.

Get Visual C# 2010 Express: http://www.microsoft.com/express/Downloads/
Get the best version of .NET for you: http://www.hanselman.com/smallestdotnet/
Aah totally forgot! Cheers for the heads up mr. Faraday!
A good tip for VS C# 2010 is to go into Tools > Settings and chose Expert Settings, which will give you back all the menu and toolbar options you would be familiar with from VS 2008.

Edit: Incidentally the release version of C# Express uses about 100mb of memory less than the beta, and appears to run much much faster.
Quote from DarkTimes :A good tip for VS C# 2010 is to go into Tools > Settings and chose Expert Settings, which will give you back all the menu and toolbar options you would be familiar with from VS 2008.

Edit: Incidentally the release version of C# Express uses about 100mb of memory less than the beta, and appears to run much much faster.

That's pretty cool, I wonder if the extra 100MB was for the debug code, and they just flipped the switch to remove the code in the compiled version.
Nah, they just hadn't optimised the new code. It had quite a few issues, as well as some pretty horrendous memory leaks, which sadly seems to be a reoccurring theme with applications written in WPF. Obviously managed code doesn't remove the necessity to manage memory, but in WPF it seems there is a tendency to have orphaned XAML elements which never get garbage collected. Pretty much all of those issues have been fixed, plus a few old things, such as the Add References dialog, have been hugely improved. Well, I know there are always people who will never be happy with Visual Studio, but I do think it's a very nice upgrade.
-
(DarkTimes) DELETED by DarkTimes
Just spotted this on HackADay - http://hackaday.com/2010/04/18 ... -sim-with-real-car-parts/ (decided it was more OT than anything else).

Granted we've seen other smaller scale stuff like that before, but its nice to see someone's work with LFS featured on such a prominent hardware hackers website
Auto Gearbox
Does anyone know where I can get a Auto gearbox like ones found on real cars? Not like the one supplied on LFS that only changes up higher within the rev range?
-
(Jakg) DELETED by Jakg

The Off Topic Programming Thread!
(309 posts, started )
FGED GREDG RDFGDR GSFDG