I was practicing on w3schools and used the Customers table (you can select it on the right hand side). As for which DBMS I'm using, I'm not sure. The site says "Our SQL tutorial will teach you how to use SQL in: MySQL, SQL Server, MS Access, Oracle, Sybase, Informix, Postgres, and other database systems." - is the syntax between those DBMS the same or very similar?
I want to extract only the first name of the customers. I thought this should do the trick:
SELECT LEFT(ContactName, CHARINDEX(' ',ContactName)-1)
FROM Customers;
It doesn't work, however, it returns nothing. As in, it doesn't process it, in the output window it shows me the start page, so there's no error message. I don't really get the actual reason behind it, because when I put CHARINDEX by itself in the SELECT statement it gives me the expected result.
Next question would've been how I deal with multiple spaces (when someone has a middle name), but since I got stuck beforehand I didn't get to this part.