802 Posted Topics
Re: I don't see any errors in the structure, so presumably it's in the data. Please show them. | |
Re: What are "3 PK's"? You can avoid trouble by setting foreign keys in the bookings table. These make sure that you cannot enter a booking with invalid IDs. And set a unique key on the driver/car combination to avoid double bookings. Like that: [CODE]create table bookings (driverID integer not null, … | |
Re: If Mysql isn't the best, as you say, how would you solve this in another DBMS? | |
Re: Also keep in mind that MySQL doesn't have a regex replace function. You might find the pattern, but you cannot replace it. You would have to use a user defined function - which might be the easiest way to tackle it, anyway, if you really have to solve it within … | |
Re: I don't understand what you're aiming at. Please provide some sample data and the desired result. | |
Re: You are applying the between operator on a character field. Therefore it does not compare dates, but literal strings. To compare dates on your data you have either to convert them to date fields or to reverse the sequence of the elements. Try: [CODE]SELECT approval_date FROM itemdetail WHERE concat(substr(approval_date,6,4),'/',substr(approval_date),4,2),'/',substr(approval_date,1,2)) BETWEEN … | |
Re: I don't see how your problem refers to mysql. In mysql you can search for date ranges with a where clause like "mydate between '2011-02-01' and '2011-03-01'. | |
Re: Use the ifnull function in your update clause: [CODE]update mytable set channel=ifnull(identifychannel(centre_code, company_class, stock_type),channel)[/CODE] | |
Re: Any concatenation with NULL results in NULL. Therefore you have to use the ifnull function: [CODE]SELECT CONCAT(ifnull(properties.PropertyRef,''), ' ', ifnull(properties.SaleType,'') ... [/CODE] | |
Re: The english spell I with a capital "I". And they use punctuation marks. It is not quite clear what you want: the person entries which appear more than once in per_db? Or the person entries where the number of occurences in per_db is the same as the value of the … | |
Re: I would prefer a solution without the priority field and with only one occurence of the search term: [CODE]select a.locationID, ifnull(alternateName,locationName) as theName, countryCode from locations l left join alternatenames a on l.locationID = a.locationID having theName like '$term%'; [/CODE] | |
Re: [ICODE]drop table if exists accounts; create table accounts (id integer, account integer, fiscalyear integer, openingbalance float ); insert into accounts values ('1','1202','2011','1122.00'), ('2','1210','2011','0.0'), ('3','1920','2011','1212.33'); drop table if exists transactions; create table transactions (id integer, account integer, date date, amount float); insert into transactions values ('1','1210','2010-01-01','23.00'), ('2','1210','2010-01-23','566'), ('3','1920','2010-01-21','456'), ('4','1202','2010-01-14','956'); select a.account, … | |
Re: I don't know the C interface but assume it's the same as PHP's. If so, you could use the [ICODE]mysql_num_rows(res)[/ICODE] result, or you could first check the row count by [ICODE]select count(*) from table3 where ID = %d[/ICODE] | |
Re: Do you mean: just the med_names and nothing else? You can of couse select them directly from the items table. But this is not what you mean, I suppose. What do you mean instead? If you want to show some kind of relationship between items and pharmacies you do need … | |
Re: Show the table defnition. In which field are your data stored? Presumably an integer field. Alter it to a time field. | |
Re: $tbl_name is not a valid table name. Please quote the complete error message and show the CREATE TABLE statment for that table. | |
Re: If the auditlog table has a primary auto_increment key, you can insert the records into a new table by selecting all fields except the auto_increment field for which you insert a NULL. Example: [CODE]insert into newtable (id, field2, field3, field4) select NULL, field2, field3, field4 from oldtable; [/CODE] This leads … | |
Re: You could also use a VPN between the clients and your server so that the database cannot be compromised via the Internet. | |
Re: Make sure that TaskDueDate contains exactly the date value you want. Or, better, alter it to a date field instead of a datetime field. | |
Re: [url]http://www.webdevelopersnotes.com/tutorials/sql/index.php3[/url] This is just a randomly picked link of the google result for "mysql primer". | |
Re: If this is an mysql problem, you can check it by logging into your mysql server with the mysql command line client with the same parameters as your website scripts. Then enter "show status" at the mysql command line. If there are a lot of processes running, your script does … | |
Re: Study the LEFT JOIN syntax and semantics. That's what you need. [url]http://dev.mysql.com/doc/refman/5.0/en/join.html[/url] | |
Re: This is called screen grabbing, and there are lots of useful techniques for it. Use wget to grab the whole site and a couple of grep and sed scripts or PHP with preg_match or other regular expressions to extract the relevant content to CSV. Then load the CSV tables into … | |
Re: Your where clause is in effect the same as [ICODE]facility_name = 'Parking' or facility_name = 'AC'[/ICODE] But what you need is [ICODE]facility_name = 'Parking' [U]and[/U] facility_name = 'AC'[/ICODE] | |
Re: First of all make sure that your set definition is complete. As of now, it lacks "Biography" and "Music". Afterwards go along those lines: [ICODE]drop table if exists movie_genre; create table movie_genre (id integer ,title text ,genre varchar(255) ); drop table if exists movie_plot; create table movie_plot (id integer ,title … | |
Re: Noob there, please write in English. 1) Use the MySQL INSERT statement. 2) Use the MySQL LOAD DATA statement. If this does not answer your questions, as I suppose, try to be more specific. | |
Re: It is not clear what your problem is. Submit some test data and the results you would like to have. I only noticed that the in the where clause [ICODE](DateSignup BETWEEN '2010-11-1' AND '2010-12-1' AND PaymentCycle = "1") OR ((DateSignup BETWEEN '2010-11-1' AND '2010-12-1' AND PaymentCycle = "12")[/ICODE] you are … | |
Re: Did you ever think of using Google? [url]http://www.developer.com/java/data/article.php/3417381[/url] | |
Re: A query can validate and still have a result with no rows. Please show your code sample. | |
Re: Your query misses a closing bracket ) For debugging purposes add a routine which shows the mysql error messages if a query has no result. Use the functions mysql_errno() and mysql_error(). | |
Re: Learn, read, study. It is the easiest way. If you run into a problem doing your homework come back for help. | |
Re: Use plain brackets () instead of curly brackets {} Add a semicolon ; after each statement (after "INNODB") | |
Re: There is no database application which you could "open". MySQL does not come with a GUI. MySQL server usually runs as a service. You can connect to the server with various command line client programs like mysql, mysqladmin, mysqldump etc. which you find in the mysql/bin folder. | |
Re: Get yourself a mysql command line client (in the MySQL installation package). Start it with the parameters you also use in ODBC. It might give you more precise error messages. A common pitfall is the format of the password. If you are using an old database server and a new … | |
Re: How can you have an index on "Group_by(clean_modelno, publishercategory) BTREE[/*]" - an index on a group by clause? This is possible? What are the results of "EXPLAIN your_query" ? | |
Re: What did you try already and what did not work as expected? | |
Re: Always provide a full test case. [ICODE]drop table if exists results; create table results (user_id integer, test_points integer, test_time integer); insert into results values (1,1,1), (1,3,2), (1,4,2), (2,1,5), (2,4,1), (2,4,0), (3,1,1), (3,2,2), (3,2,1); /* expected results : 2 4 0 1 4 2 3 2 1 */ select user_id, test_points, … | |
Re: Build a reference table with all month names and left join it to your data table. | |
Re: An XML (or object) database would be appropriate for highly hierarchical data which cannot be properly organized in tables. This might be the case if the objects have disparate and different attributes (fields) with little or no common subsets. Your data sample seems to be a quite ordinary sample for … | |
Re: Join the tables on the field userid and use there WHERE search for the name only on the user table. [CODE]$sql = "mos_users.id as userid, block, username, email, lastvisitDate, firstname, lastname, avatar, cb_age, userip FROM mos_users, mos_comprofiler, mos_comprofiler_plug_iplog WHERE mos_users.username = '". $user."' AND mos_comprofiler.user_id = mos_users.userid AND mos_comprofiler_plug_iplog.userid = … | |
Re: [CODE]select surname, subj_name, mark from student st left join exam_marks em on st.stud_id=em.stud_id join subject su on em.subj_id=em.subj_id [/CODE] If this does not fit your needs, please post a complete test case with table structure, test data, your query, the expected results and the actual results. Then it will become … | |
Re: This seems to be not so trivial as it looks. You have to find not only some distance between two actors, but the minimum distance. This means that you have to scan all possible paths from actor1 to actor2, including the possibility that they are not connected at all. I … | |
Re: To retrieve the values, use a SELECT query. Study the JOIN syntax ([url]http://dev.mysql.com/doc/refman/5.1/en/join.html[/url]) and give it at least a try before you ask for help. Come back when you cannot work it out. To create a table with those values, use the CREATE TABLE AS SELECT ... syntax ([url]http://dev.mysql.com/doc/refman/5.1/en/create-table.html[/url]) | |
Re: Permanent settings are in Linux stored in /etc/mysql/my.cnf or /etc/my.cnf, depending on the distribution. On a Mac you probably won't find the file and you'll have to create it. See [url]http://forums.mysql.com/read.php?11,366143,376017#msg-376017[/url] | |
Re: This would be a task for a cron job. MySQL has date/time functions, so you could write a trigger which checks and updates a time value on every operation (update,insert,delete), but it would not do anything without such an operation. You could also code something like [CODE]select unix_timestamp('2012-01-01') - unix_timestamp(now()) … | |
Re: What means "optimum code" ? In number of code lines? In performance? In usability? Maybe I would try to solve this not in MySQL but in plain text format on a dump file with regular expressions (grep or, in PHP, preg). This could be the optimum in coding efficiency. | |
Re: To be more precise, the trigger should not check how many but the maximum id value for cars of this brand and then add one. | |
Re: Convert your first procedure to a function which returns the desired value and call it from your 2nd procedure. Apart from that this looks like nonsense to me. What for do you need a stored procedure which does nothing than insert a row into a table? | |
Re: You cannot use the '+' operator for character strings in MySQL. Use the concat function instead. [CODE]$query = "SELECT partID, fname, lname FROM tblPartInfo WHERE lname LIKE concat('$lname','%') or fname LIKE concat('$fname','%')"; [/CODE]Or change your PHP code to [CODE]$query = "SELECT partID, fname, lname FROM tblPartInfo WHERE lname LIKE '$lname" … | |
Re: Do you have access to a backup file in plain text format? |
The End.