Display of a column in alphabetical order

[expired user #1386]'s profile image [expired user #1386] posted 8 years ago in General Permalink

I want to display all the lines of my database with the names in the first column in alphabetical order. Clicking the head of the column (which normally should order the names in ascending/descending order) gives erratic results.

ansgar's profile image ansgar posted 8 years ago Permalink
  • By "lines in your database" you mean "rows in your table" ?
  • No clue what you mean by erratic results. You could post a screenshot of the sorted grid.
[expired user #1386]'s profile image [expired user #1386] posted 8 years ago Permalink

Hi Ansgar, No, I mean lines of data (there are 15 rows in my table, and about 1,353 rows of data). By erratic results I mean that rows appear in blocks of, say, 50 rows in alphabetic order, followed by 20 other rows in alphabetic order, and so on.

1 attachment(s):
  • Extract-DB-tumlatum
ansgar's profile image ansgar posted 8 years ago Permalink

Could you please post some CREATE TABLE code and the SELECT...ORDER BY query you are executing.

[expired user #1386]'s profile image [expired user #1386] posted 8 years ago Permalink

I only want to sort all the lines according to the 1st column with its content (Compositeur) in alphabetical order (in my case the top line being ALBINONI, and the last one ZIPOLI). In the data window I select all 15 columns, and "Tout montrer" (Show All -- which should list all the lines). But all the Composers are not shown in alphabetical order... What is the correct syntax: select * from label order by Compositeur ASC ?

1 attachment(s):
  • Wrong-alphabetical-order
ansgar's profile image ansgar posted 8 years ago Permalink

Yes, correct.

[expired user #1386]'s profile image [expired user #1386] posted 8 years ago Permalink

Despite numerous assays I still cannot get all rows with the first column in alphabetical order. How can I arrive to a correct view?

1 attachment(s):
  • Composer-not-in-alphabetical-order
ansgar's profile image ansgar posted 8 years ago Permalink

You posted a SELECT ... ORDER BY xyz query, but the screenshot is from the "Data" tab. You need to run that SELECT query in a "Query" tab, not in the "Data" tab.

[expired user #1386]'s profile image [expired user #1386] posted 8 years ago Permalink

Ok,thanks. But even from a new "Query" tab I receive Error 1064 syntax error near classiques at line 1...

1 attachment(s):
  • Erreur-1064
ansgar's profile image ansgar posted 8 years ago Permalink

syntax error near classiques

I thought your query was

SELECT * FROM label ORDER BY Compositeur ASC
[expired user #1386]'s profile image [expired user #1386] posted 8 years ago Permalink

Yes, my query was that one. Why then this Error SQL 1064, what's wrong with this syntax?

ansgar's profile image ansgar posted 8 years ago Permalink

Your query was

SELECT * FROM label ORDER BY Compositeur ASC

and the error message is syntax error near classiques ??

Can't believe that...

[expired user #1386]'s profile image [expired user #1386] posted 8 years ago Permalink

Please trust me. I made the same request once more, with the same result. This message is not very informative. Looking at the preceding lines as well as the succeeding lines I don't find any syntax error. Perhaps there is something that escapes me...

1 attachment(s):
  • Erreur-1064
ansgar's profile image ansgar posted 8 years ago Permalink

Man, you could have mentioned that you have a USE xyz query also...

That's the cause of the problem. The database name disques classiques has a space in it, so you need to quote it with backticks:

USE `db with space`;
[expired user #1386]'s profile image [expired user #1386] posted 8 years ago Permalink

OK, thanks this trick solves my problem. But now I can't understand why this INSERT doesn't work (see the attached screenshot). Even when suppressing the IGNORE, or changing it by REPLACE. I am lost.
PS. My only guide to SQL is MySQL in a nutshell (O'Reilly Ed.).

1 attachment(s):
  • INSERT-HUMMEL
kalvaro's profile image kalvaro posted 8 years ago Permalink

I have the impression that you've dismissed the error message as being internal information of no interest for the developer. It means what it says: you provide values for one column but your table has more that one column, hasn't it?

Whatever, a support forum for a given piece of software is hardly ever a good place to teach yourself a language. I suggest you find a SQL forum.

Please login to leave a reply, or register at first.