802 Posted Topics
Re: How does a single entry look like? How do you compute bags_packed? Is it a sum or a count or a field value? | |
![]() | Re: Mysql has a nifty function for it: group_concat Like in [CODE]select org_name, group_concat(activity_name) from organisation o, activities a, org_activity oa where o.org_id=oa.org_id and oa.activity_id=a.activity_id group by o.org_id ;[/CODE] (Code not tested) Alternatively you may look at the various JOIN syntax varieties of MySQL. ![]() |
Re: Storing computable values is never a good idea, except for caching and performance reasons. You could define a query or a view instead like as [CODE]select *, date_add(registration_date, interval 6 month) as subscription_end from mytable; [/CODE] | |
Re: I cannot confirm your observation. Here my test code with results: [CODE]drop table table1; drop table table2; create table table1 (acct_no VARCHAR(15) ,column1 varchar(10) ); create table table2 (acct_no VARCHAR(12) ,column2 varchar(10) ); insert into table1 values ('1',1), ('2',2); insert into table2 values ('1',1), ('2',2); [/CODE] [CODE]SELECT a.acct_no,a.column1,b.column2 FROM table1 … | |
Re: [I should know better than to help with an MLM enterprise.] First I would try the performance of your attempt with the expected number of participants. MySQL can be quite performant, so maybe there is no need to change your code. But probably you would be better off with another … | |
Re: You have to reset your query cursor. After walking through the result with mysql_fetch_array once there are no more records to be retrieved. Insert [ICODE]mysql_data_seek($users,0)[/ICODE] at the end of the inner loop. | |
Re: [url]http://dev.mysql.com/doc/refman/5.1/en/windows-installation.html[/url] | |
Re: Depending on your MySQL setup it might be that you have to use the OLD_PASSWORD function: [url]http://dev.mysql.com/doc/refman/5.1/en/encryption-functions.html#function_old-password[/url] | |
Re: You are probably looking for the mysql function LAST_INSERT_ID() | |
Re: Have a look at the date/time functions: [url]http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html[/url] To avoid conversion issues use something like [CODE]SELECT * FROM timetable WHERE unix_timestamp(time) - unix_timestamp() < 3600 [/CODE] Alternatively you could use the timediff() function. | |
Re: You would need a limit clause in your subquery, but MySQL doesn't support this yet. And since you are mixing logic and layout anyway, maybe you would be better off using a procedural language to display your query results. What do you mean by but [QUOTE]I just cannot get it … | |
Re: You have to grant the appropriate permissions on your MySQL DB. See [url]http://dev.mysql.com/doc/refman/5.0/en/grant.html[/url] In the MySQL client you have to enter something like: [CODE]Grant all privileges on * to myName@% identified by `myPassword` [/CODE] or, more restrictively, [CODE]Grant all privileges on * to myName@myHomeIP identified by `myPassword` [/CODE]and a [CODE]Flush … | |
Re: You have to group your query by the date: [CODE]select date(from_unixtime(registered)) as theDate, count(*) from ucard group by date(from_unixtime(registered)) [/CODE] For further help please submit the table structure and some test data. | |
Re: Long ago I used MS Access as an interface to MySQL (via ODBC) which then had a designer with vizualization of the table relationships. Navicat has a view designer with some vizualization, but not for table relationships, only for views. Nowadays I prefer the command line mysql over any of … | |
Re: What did you try already that did not work for you? | |
Re: Maybe your client gets angry because you promised too much? Are your tables encoded in UTF? Please submit the table design, some test data and a query which should work but does not. | |
Re: Start here: [url]http://www.freewebmasterhelp.com/tutorials/phpmysql[/url] | |
Re: There are more than one problems with your syntax. The INDEX() clause does not necessarily need a name, but at least one field. The name goes before the brackets, the indexed fields inside them. The FOREIGN KEY clause needs the name of the foreign key column inside the brackets. The … | |
Re: I would go with your proposal 1: Have 1 database with all tables and filter the content depending on the users. This can become tricky, though, if the users have an interface which allows them to directly update the contents of their views. Proposal 2 is, as you say, bad … | |
Re: Use an IF clause, like in [CODE]select sum(amount * if(ordertype='BUY',1,-1)) from mytable[/CODE] If this does not suit your needs, submit a test case. | |
![]() | Re: Or drop the quotes altogethere where you do not need them. With table and field names without spaces you need neither quotes nor backticks. |
Re: As far as I understood it the query optimization uses only one of the indexed fields in the query execution. For some reasons it concludes that this field is CATEGORY_ID and therefore chooses an index which contains this field. The second field in your index is not taken into consideration … | |
Re: So which part of your problem is it you don't know? Have a look at the server variables like $_SERVER['REQUEST_URI'] and the preg_replace function. Anything else you need? | |
Re: If the numerical fields are either 0 or the desired value, you may use the maximum of each field. Replace your IF clauses by max() [ICODE]if(o.sales_stage='Prospecting', o.amount, '') as PROSPECTING[/ICODE] becomes [ICODE]max(o.amount) as PROSPECTING[/ICODE] in your query. Or, if you have several rows for each category, you might use the … | |
Re: To the best of my knowledge you cannot do this in SQL or MySQL, for that matter. If you have access to PHP, you can read all column names in an array with mysql_field_name() and then sort and traverse the array. Also have a look into the INFORMATION_SCHEMA database which … | |
Re: This is a bit tricky, but with a subselect it can be done: [CODE]select ExamId,StudentId,Mark from marks where (ExamId,Mark) in (select ExamId as e, min(mark) as mm from marks group by ExamId);[/CODE] The proposal of genevish is no solution since it refers to tables which are not accessible. Always include … | |
Re: Your query is fine. The database server crash must have other reasons. | |
I'm setting up a SOAP service using the PHP SOAP server and client library. I've coded some structured data types into my wsdl file with some heavy restrictions. Do you know of functionality in the PHP SOAP library or of a 3rd party library which will check the actual parameters … | |
Re: First try to solve your MySQL problem, then the PHP problem. Submit a test case which contains the relevant CREATE TABLE statements, some INSERT statements to fill the tables with test data and your query which goes amiss. Then anyone will gladly try to look into your problem. As of … | |
Re: Your desired result differs from your statements about it. Why does [ICODE](1,query 2,[url]http://yyy.co.uk/,1288051200[/url])[/ICODE] appear twice in your result set? In which respect is it different from the first line? Maybe you are aiming at something like [ICODE]select min(place),query,fullurl,date from places group by query,fullurl,date;[/ICODE] But it is really hard to tell … | |
Re: [CODE]insert into ZTable1 select 1, ZTable.* from ZTable [/CODE] Or maybe you want [CODE]insert into ZTable1 select TId,TId,TName,TAge from ZTable [/CODE] It's hard to tell from your post. | |
Re: You are confusing levels. On one level (presumably PHP) you are building your query, on the MySQL level you are executing it. To get rid of the the trailing " and" in your query use something like $query = substr($query, 0,length($query)-4) or whatever is appropriate in the used language. Alternatively … | |
Re: You could map the character values to a reference table which contains characters and their numerical equivalent, query a join of both grade and reference table and select the average number value from the reference table. Or you could code a function which returns a numerical value for each character … | |
Re: I don't find an "EXEC" statement in the MySQL manual. Do you? Depending on your aims, maybe you should have a look at prepared statements in MySQL. See also: [url]http://forums.mysql.com/read.php?98,19285,19285#msg-19285[/url] | |
Re: In my version of MySQL (5.1.34-community) your code produces the desired error: [CODE]Field 'name' doesn't have a default value[/CODE] So after your INSERT there is really a new row in your table? Or do you just suppress the error messsages? | |
Re: The line [CODE]ON (topics.managerId = quiz.".$managerId.") [/CODE]should read [CODE]ON (topics.managerId = quiz.managerId)[/CODE] By the way: you don't have to exclude PHP variables from double quotes. [ICODE]WHERE topics.$egroup = 1[/ICODE] is easier to read than [ICODE]WHERE topics.".$egroup." = 1[/ICODE] | |
Re: You forgot the GROUP BY: [CODE]drop table if exists recipes; create table recipes (id integer ,name varchar(255) ,cat varchar(255) ,instructions text ); insert into recipes values (1,'Tacos','Mex.','Mix and Serve'), (2,'Kabobs','Beef','Combine/Grill'); drop table if exists ingredients; create table ingredients (id integer, recipe integer, qty integer, measurement varchar(255), ingredient varchar(255) ); insert … | |
![]() | Re: You seem to have reset the admin password with [ICODE]mysqladmin -u root password "newPassword"[/ICODE] Afterwards you try to connect but you do not provide a password, as proven by [ICODE]error: 'Access denied for user 'root'@'localhost' (using password: NO)'[/ICODE] Could it be that you just forgot the password option -p as … ![]() |
Re: Do you mean that you want to select all records from table A with an x/y combination (x,y being field names) which does not occur in table B? That would be [CODE]select A.* from A left join B on A.x=B.x and A.y=B.y where B.x is null [/CODE] | |
Re: You should solve the math on mysql level, not in php. Have a look into the date/time functions: [url]http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html[/url] | |
Re: Who should know but you? It all depends what the data are used for. But always include an auto_increment id field in your tables (except for m:n tables) which will make your life much easier. | |
Re: $GLOBALS['MySQL'] is obviously not an object. It should have been created by $GLOBALS['MySQL'] = new BxDolDb(); This seems to have failed. Try to connect using the standard MySQL client from the command line with the same parameters as coded somewhere in your included scripts. This might be a compatibility issue … | |
Re: MySQL only allows for sorting on values, may they be field values or function results or constants or whatever, but not on the order of entry into the db. In a client program like phpMyAdmin you could list the data in reverse order, though, by having a routine like [ICODE]for … | |
Re: Since Mysql keeps track of the number of changed rows (which it displays after every update) I assume that the system retrieves the current field values before updating them in both cases, so the unconditional update (for all rows) should be slower than the filtered one. This would also depend … | |
Re: Your query is syntactically wrong (WHERE clause after ORDER clause) and semantically wrong because 1. you want to select "WHERE id IN" instead of "WHERE id =" and 2. you do not need to sort the subquery because the sorting is done in the master query. | |
Re: [CODE]select distinct studentid from results where studentid in (select studentid from results where course='mam1') and studentid in (select studentid from results where course='phy2'); [/CODE] Test: [CODE]drop table if exists results; create table results ( studentid integer, course varchar(10), percent integer ); insert into results values (1001,'mam1', 63), (1002,'phy2', 55), (1002,'mam1', … |
The End.