802 Posted Topics

Member Avatar for iamnot

Store images and text in different columns, use CSS classes for image position and store the CSS class name with the option.

Member Avatar for smantscheff
0
195
Member Avatar for RachelR

You can group all rows by their due date and concatenate the task names using the group_concat function. Along those lines: select (if due_date < now(), 'overdue', if( due_date < date_add(now(), interval 1 day), 'today', due_date)) as "Due date", group_concat(taskName) as "Tasks" from MyTaskTable group by "Due date"; This is …

Member Avatar for smantscheff
0
191
Member Avatar for David2012

To increase safety, you should also - restrict user access to the database to the IP address of your webserver, so that no intruders from outside can read the database; - store the access data (username, database name, password) in a separate file with a name beginning with a dot …

Member Avatar for David2012
0
176
Member Avatar for maad_jhangir

What kind of a setup is this where a user may handle all databases except one? Sound like Bluebeard's Lair. If I ever had this problem I would write a script (on OS level) which processes a list of database names, a username and an exception name as arguments and …

Member Avatar for maad_jhangir
0
218
Member Avatar for london-G

You cannot INSERT with a WHERE condition. You can UPDATE or DELETE with a WHERE condition.

Member Avatar for smantscheff
0
181
Member Avatar for designalex

This is bad table design. veh_status should be a separate table with a 1:n relation between vehicles and veh_status.

Member Avatar for rch1231
0
209
Member Avatar for nonshatter

The problem probably was not a data mismatch but a data type mismatch. InnoDB requires exactly the same data type in relations, so you cannot link an integer(11) to an integer(5) field.

Member Avatar for smantscheff
0
4K
Member Avatar for hassanumair1

In practice, limits are set by the hardware, not the software. If your budget allows for adding new nodes as necessary, mysql in the partitioned version is capable of bookkeeping all particles in the universe.

Member Avatar for smantscheff
0
179
Member Avatar for amcfarland

If they have all the same structure just concatenate them into one file and import it. If this is not sufficient, have a look at the LOAD DATA INFILE command and the mysqlimport utility.

Member Avatar for drjohn
0
64
Member Avatar for mancode1007
Member Avatar for jward50

You could create a temporary table which links the taxonomy_index.tids to the column labels and use it in a left join construction. For further help post a test case, including CREATE TABLE and INSERT statements.

Member Avatar for smantscheff
0
92
Member Avatar for crackme
Member Avatar for crackme
0
152
Member Avatar for marietta_kan

Show the complete CREATE TABLE statement. Make sure that both waiter.id_w and customer_1.id_w have an index. The InnoDB engine needs an index on all fields which are used in a foreign key relation.

Member Avatar for smantscheff
0
119
Member Avatar for fabzster

It all depends. If your app does not store any user input which would be overwritten by the uploads, this might work. Keep in mind, though, that the standard mysqldump program inserts code which disables reference integrity checks (for performance reasons, I assume). And if your database is large, the …

Member Avatar for smantscheff
0
157
Member Avatar for Acute

Your attempt is definitively flawed. If you implement it like that, a deletion of a post may lead to the deletion of reports on comments with the same id. Another solution might be to combine posts and comments in one table, since they only differ in the reference to a …

Member Avatar for smantscheff
0
175
Member Avatar for anand01

Show some test data and the unexpected as well as the expected results.

Member Avatar for anand01
0
146
Member Avatar for hwoarang69

Also keep an eye on the new argentine legislation where you are free to choose your gender as you like, and on the european discussion on transgender people. Might be that boolean is not the correct datatype for gender after all. In modern applications I'd recommend at least four choices: …

Member Avatar for seslie
0
192
Member Avatar for doodalf

It is not clear what your problem is. Or how you tried to solve it. You can sort and group your table by race and forecast. If that's what you want, try `select * from races order by race, forecast ` If you want an explicit "rank", count the number …

Member Avatar for smantscheff
0
174
Member Avatar for ebanbury

The + operator does not concatenate strings. Use Concat() instead. And beware of SQL injection. `$_GET[agent_name]` is likely to get you into trouble

Member Avatar for ebanbury
0
184
Member Avatar for yanwick

The character set is a property of the server, the database, the table and the field - in that order. Each has a default which can be overwritten by the following. You can change it using the `alter table` syntax. Then there is the client and the connection character set …

Member Avatar for yanwick
0
234
Member Avatar for Szabi Zsoldos

What does EXPLAIN <query> tell you? Also have a look at http://code.openark.org/blog/mysql/7-ways-to-convince-mysql-to-use-the-right-index to get some optimization ideas.

Member Avatar for maniat123
1
229
Member Avatar for karanits

You need some sort of chaining of the records. Add a field like NextTransactionID or PreviousTransactionID which will allow you to insert and delete records without breaking any chains.

Member Avatar for karanits
0
1K
Member Avatar for jimdj

From a philosophical point of view you cannot alter anything in a database without altering its information, because structure and data are what database information consists of. Even if you add only a column with no data or an enum value which is never used the semantics of the database …

Member Avatar for seslie
0
159
Member Avatar for showman13

Use the IF or IFNULL function: SELECT mem_id, IFNULL(company, CONCAT(fname, ' ', lname)) as theName, addr1, addr2, city, state, zip, country FROM dc_order WHERE STATUS='W' or SELECT mem_id, IF(length(company) > 0, company, CONCAT(fname, ' ', lname)) as theName, addr1, addr2, city, state, zip, country FROM dc_order WHERE STATUS='W'

Member Avatar for smantscheff
0
132
Member Avatar for whitecoder

You don't even need any IF for your condition, because like '%%' matches just all content, so you don't have to test for empty variables: $sql = sprintf( "SELECT * FROM property WHERE id > 0 and city like '%%%s%%' and state like '%%%s%%' and county like '%%%s%%' and status …

Member Avatar for smantscheff
0
2K
Member Avatar for jakubee

Probably you forgot to change the delimiter before creating the trigger. DELIMITER // create trigger ins_notification after insert on transaction_detail for each row Begin insert into sell_notifications(user_id, product_id, quantity) values(new.transaction_id , new.product_id, new.quantity); End // DELIMITER ; Though this would be much easier to verify if you showed us the …

Member Avatar for smantscheff
0
91
Member Avatar for wipeskim

Your query would be fine if you replace 'day_add' by 'date_date': mysql> create table d (day_date date, price integer, allotment integer); Query OK, 0 rows affected (0.03 sec) mysql> insert into d values -> ('2012-05-20','500','2'), -> ('2012-05-21','500','2'), -> ('2012-05-22','500','2'), -> ('2012-05-23','600','4'), -> ('2012-05-24','600','4'), -> ('2012-05-25','500','7'), -> ('2012-05-26','500','7'), -> ('2012-05-27','700','2'), -> …

Member Avatar for smantscheff
0
167
Member Avatar for erogol

The location of the database files depends on the `datadir` configuration variable in my.ini (or my.cnf, depending on the installation). This configuration file usually resides in the root directory of your mysql installation. But, as drjohn suggests, better export the whole database. `mysqldump` is a command line utility which comes …

Member Avatar for smantscheff
0
272
Member Avatar for DaveyMoyes

Change your code to if (strlen($img1)) $img_list .= "<img src='$img1' width='268' height='269' title='$title' alt='$title'/>"; or better if (file_exists($_SERVER['DOCUMENT_ROOT'] . $img1)) $img_list .= "<img src='$img1' width='268' height='269' title='$title' alt='$title'/>";

Member Avatar for smantscheff
0
137
Member Avatar for |-|x

The exception is thrown already in the query analysis. Try to EXPLAIN your queries and you will see that the first EXPLAIN has a result while the second one is already rejected without the query being actually executed. So I'm not sure where the short-circuiting occurs - not in the …

Member Avatar for |-|x
0
2K
Member Avatar for A T Smith

To retrieve all allowed enum values you have to read the table definition. Use the "show create table" statement and parse it for the enum field definition.

Member Avatar for blocblue
0
138
Member Avatar for Sonia11

What is a mysql file? A script containing mysql statements? Read more about it [here](http://dev.mysql.com/doc/refman/5.0/en/comments.html)

Member Avatar for MarPlo
0
80
Member Avatar for nova37

urtrivedi's solution assumes that the (id,domain) tupels are the same in 1X and 2X, i.e. that the IDs for all domains are the same in both tables. Since I do not believe this to be the case and since ID presumably is an auto_increment field, change the above suggestion to: …

Member Avatar for smantscheff
0
214
Member Avatar for |-|x

If there is always a second entry with the same 'ver' value as the latest, you might try: select * from tblp where (invoice IS NOT NULL) order by latest desc, ver desc limit 1,1

Member Avatar for |-|x
0
155
Member Avatar for riahc3

You could use the concat function: select * from mytable where concat(field1,field2,field3...) like '%searchtext%' This is highly inefficient, but with small databases it works. An alternative is to export (dump) the database to a text file and then search with grep or a text editor.

Member Avatar for smantscheff
0
438
Member Avatar for showman13

A cleaner table structure would have made this easier. I'd propose to have a separate position table as a n:1 child table of members which records the positions: [CODE]create table positions (mem_id integer not null, position enum(1,2,3,4,5,6,7), foreign key (mem_id) references members (mem_id)); [/CODE]Then you could state your query as: …

Member Avatar for smantscheff
0
233
Member Avatar for ilyons

It all dependes. Does your table has relations to other tables? Is the primary key used as a foreign key elsewhere? Do you have orphaned records in relations? If all this is no problem, the easiest way would be this: Restore the backup table in a backup database (here called …

Member Avatar for ilyons
0
294
Member Avatar for |-|x

1) You cannot mix aggregate functions with non-aggregate fields with valid results. If you group by p.field1, what would you expect in result for the tupels (field1, field2) = (1,1), (1,2), (2,1),(2,2) ? Should the query return 1 or 2 as the value for field2? The database cannot decide that. …

Member Avatar for |-|x
0
214
Member Avatar for Jfunch

select b.brand, c.category from (SELECT DISTINCT brand from product) b, (SELECT DISTINCT category from product) c

Member Avatar for smantscheff
0
103
Member Avatar for BThomps

Drop the foreign key relations. Modify all three tables to the same data type. Re-create the foreign key relations.

Member Avatar for BThomps
0
157
Member Avatar for anime_stargazer

This design is so bad it hurts. Do not copy records from one table to another to change their status. Just add a status column, as cereal suggested. Then your code is flawed. You assign some statement text to the $sql variable, but never excecute the INSERT query. Only the …

Member Avatar for smantscheff
0
2K
Member Avatar for riahc3

SELECT in a stored procedure does not display anything. Therefore you cannot use it for debugging. In your 2nd sample you have a type: ANDA instead of AND. campo is not the same variable as @campo.

Member Avatar for smantscheff
0
184
Member Avatar for riahc3

Look for the value of datadir in /etc/mysql/my.cnf or /etc/my.cnf, respectively. Usually it's /var/lib/mysql. Unintall mysql with apt-get. Delete this data directory with all subdirectories. Delete all in /etc/mysql and /etc/my.ini, /etc/my.cnf etc. Re-install mysql.

Member Avatar for riahc3
0
429
Member Avatar for danielsikes

Depending on the size of your database it might be feasible to use concat: select group_id from search where '%somebody%' like group_concat(value, ' ') and '%special%' like group_concat(value, ' ') group by group_id;

Member Avatar for mehfooz
0
183
Member Avatar for Sonia11

Or make the field an enum type which allows only the predefined values.

Member Avatar for smantscheff
0
87
Member Avatar for Dani

You will definitively have less problems if all your stuff - database, scripts, html templates etc. - are in utf-8. If this is a hassle with phpMyAdmin, use a fine database editor like Navicat or HeidiSQL. If your site has the proper "encoding" attributes in header and meta taga, then …

Member Avatar for smantscheff
1
344
Member Avatar for Sonia11

You can use the primary key in one table as a foreign key in as many tables as you like. You get constraint errors if your data are not consistent - if you insert a foreign key which does not exist as a primary key or if you delete a …

Member Avatar for BitBlt
0
293
Member Avatar for DarkMonarch

There is no right way. A standard method is a mysql script which you feed first into your development database, then, if all is fine, into your production database, and which contains all necessary statements for table creation and the initial population with test data. You should not do that …

Member Avatar for DarkMonarch
0
116
Member Avatar for declancarey

Aquilax* solution supposes that the entry date cannot be changed manually after inserting the records. If it can, the query should rather read [CODE]SELECT Score FROM scores ORDER BY [B]date[/B] DESC LIMIT 1;[/CODE]

Member Avatar for smantscheff
0
108
Member Avatar for fire eaters

Presumably you use InnoDB tables on your localhost and MyISAM tables on the web server. MyISAM does not support foreign keys with cascading updates and deletes, but it accepts the syntax without error messages.

Member Avatar for smantscheff
0
141

The End.