I want to select all columns from a table except one column using MySQL. I know we can select all columns using this  &lt;?php $query = SELECT * FROM posts; ?&gt;   But how can I leave one specific column from the table?
30879
I'm trying to use a select statement to get all of the columns from a certain MySQL table except one. Is there a simple way to do this?  EDIT: There are 53 columns in this table (NOT MY DESIGN)
25277
I need an aggregate function that MySQL doesn't provide.  I would like it to be in MySQL's flavor of SQL (that is, not in C).  How do I do this?  What I'm stuck on is creating an aggregate function -- the  don't seem to mention how this is done.  Examples of desired usage of a product function:  mysql&gt; select product(col) as a from `table`; +------+ | a    | +------+ |  144 | +------+ 1 row in set (0.00 sec)  mysql&gt; select col, product(col) as a from `table` group by col; +-----+------+ | col | a    | +-----+------+ |   6 |   36 | |   4 |    4 | +-----+------+ 2 rows in set (0.01 sec)
19536
I'm thinking of having a program that dynamically creates new tables as the need arises. Can I have tables named with just numbers in MySQL?
70181
I have a table and I am always getting the data by ordering a column. In my case, I  order by datenum. However, the selection is so slow because of the ordering.  Is it possible to order the table after datenum. This column is defined as unique. If  defined as an index, would the selection will be faster?
2549
I have 2-3 different column names that I want to look up in the entire DB and list out all tables which have those columns. Any easy script?
46559
One of my columns is called from. I can't change the name because I didn't make it. Am I allowed to do something like SELECT from FROM TableName or is there a special syntax to avoid the SQL Server being confused?
45100
I have a simple mysql table which I use as a server booking system. A user can log in to a server, if he has a valid booking for that server. A sample data might look like this:  +----------+----------------+---------------------+---------------------+ | server   | user           | start               | end                 | +----------+----------------+---------------------+---------------------+ | server01 | Alice,Bob      | 2013-10-28 00:00:00 | 2013-12-31 00:00:00 | | server02 | Carlos         | 2013-10-28 00:00:00 | 2013-12-31 00:00:00 | | server03 | Dan,Erin,Frank | 2013-10-28 00:00:00 | 2013-12-31 00:00:00 | +----------+----------------+---------------------+---------------------+   To check whether user Carlos has a booking for server02, I use the following SQL query:  SELECT 0, id FROM booking WHERE user = 'Carlos' AND (( start &lt; now() and end &gt; now() ) AND server = 'server02') ;   But this query does not work if there are multiple (comma-separated) users. How can I check if Alice has booking for server01 ?
73168
I'm trying to create a query like this:  SELECT DISTINCT ON (field1, field2) field1, field2, field3 FROM table1   But can't figure out how to get DISTINCT ON narrowed down to a few fields in Drupal like that. Calling $query-&gt;distinct() just seems to structure the query like this:  SELECT DISTINCT field1, field2, field3 FROM table1   I did figure out a hacky way to add what I want by adding an expression before I add any fields like this:  $query-&gt;addExpression('DISTINCT ON (field1, field2) field1', 'field1');   Which creates:  SELECT DISTINCT ON (field1, field2) field1 as field1, field2, field3 FROM table1   I'm looking for a better way to this ?
14520
For example, mysql quote table name using   SELECT * FROM `table_name`;   notice the `   Does other database ever use different char to quote their table name
60119
Is there a way to restrict certain tables from the mysqldump command?  For example, I'd use the following syntax to dump only table1 and table2:  mysqldump -u username -p database table1 table2 &gt; database.sql   But is there a similar way to dump all the tables except table1 and table2? I haven't found anything in the mysqldump documentation, so is brute-force (specifying all the table names) the only way to go?
64916
How can I exclude one specific post from a WP_Query query? (For example, show all posts apart from a post with the ID 278)  I've tried the post__not_in argument but it just removes all posts..  Any help would be great.  Here is my current query  &lt;?php     $temp = $wp_query;     $wp_query= null;     $wp_query = new WP_Query(array(         'post_type' =&gt; 'case-study',         'paged' =&gt; $paged,     ));     while ($wp_query-&gt;have_posts()) : $wp_query-&gt;the_post(); ?&gt;   Thanks
106704
Which is the valid syntax of this query in MySQL?  SELECT * FROM courses WHERE (now() + 2 hours) &gt; start_time   note: start_time is a field of courses table
49941
I'm interested in learning some (ideally) database agnostic ways of selecting the nth row from a database table. It would also be interesting to see how this can be achieved using the native functionality of the following databases:    SQL Server MySQL PostgreSQL SQLite Oracle   I am currently doing something like the following in SQL Server 2005, but I'd be interested in seeing other's more agnostic approaches:  WITH Ordered AS ( SELECT ROW_NUMBER() OVER (ORDER BY OrderID) AS RowNumber, OrderID, OrderDate FROM Orders) SELECT * FROM Ordered WHERE RowNumber = 1000000   Credit for the above SQL:   Update: See  regarding the SQL standard. Troels, have you got any links we can cite?
17089
I want to search in all fields from all tables of a MySQL database a given string, possibly using syntax as:  SELECT * FROM * WHERE * LIKE '%stuff%'   Is it possible to do something like this?
67515
Ok, here is my dilemma I have a database set up with about 5 tables all with the exact same data structure. The data is separated in this manner for localization purposes and to split up a total of about 4.5 million records.  A majority of the time only one table is needed and all is well. However, sometimes data is needed from 2 or more of the tables and it needs to be sorted by a user defined column. This is where I am having problems.  data columns:  id, band_name, song_name, album_name, genre   MySQL statment:  SELECT * from us_music, de_music where `genre` = 'punk'   MySQL spits out this error:  #1052 - Column 'genre' in where clause is ambiguous   Obviously, I am doing this wrong. Anyone care to shed some light on this for me?
31050
I need to run a query like:  SELECT p.id, p.name,         (SELECT name            FROM sites s           WHERE s.id = p.site_id) AS site_list   FROM publications p   But I'd like the sub-select to return a comma separated list, instead of a column of data.  Is this even possible, and if so, how?
11491
I know that in MySQL at the command line I can reset a table's auto-increment field to 1 with this:  ALTER TABLE tablename AUTO_INCREMENT = 1   I am curious if there is a way to do this from within phpMyAdmin.  Something like a check box to reset the auto-increment or something else along those lines?  Not that there is anything wrong with the command line approach.  More one of those curiosity things I keep thinking on...  Thanks in advance!