-
Posts
5,977 -
Joined
-
Last visited
-
Days Won
148
Everything posted by gizmola
-
Not really. You could use a group by group & item to get the sum(hits). This would give you everything you needed in one query, but you would still have to go through it and discard the items in each group which were not the top 3 in each group. This *might* be more efficient than what you are doing (a seperate query for each group) assuming you have a limited number of total items. The query would be something like: select a.group, a.item, sum(hitcount) as hitcount from item a, hits b where b.item = a.item group by a.group, a.item order by a.group, hitcount
-
All design decisions like this involve tradeoffs. BBS polls are very simple because they can ask only one question, and then have a fixed set of answers that are always an enumerated list. Since they wanted to KISS, they used a compressed non-database centric structure. If your application was focused on polls, then this might be a bad decision, but since polls are essentially fluff in the context of a forum, it really doesn\'t matter. In their case they opted for a structure that is storage friendly but computationally taxing. This however allows them to focus on the forum code and be database agnostic which was probably one of their design goals.
-
Mysql is a table locking database. Selects/inserts and updates all lock the table... so queuing is an intrinsic function of the database. Mysql uses priorities... the default is that writes are processed in the order received, and have a higher priority than reads. Nevertheless, Reads also lock the database from writes. By default LOCK TABLES will block/wait until it gets all the table locks you are asking for.
-
Well I\'m gonna eat my words on this one a bit... mysql kinda sucks in numeric presentation. Again if you really want to do this apparently you need to specify a width attribute for the column (in your case 2) with the zerofill attribute. When you do selects, the numbers will come out with leading zeros. Again, none of this necessary if you just use a Date, which gives you the great date formatting.
-
Not really... and it is the best way to handle your problem My only quibble is that you should use $_POST rather than the $HTTP_POST... Your code btw, is completely incorrect, because all you are checking is whether your query completed or not. It would almost certainly always be true (assuming you didn\'t have a syntax error in your statement).
-
Get into the database and use mysql; Select * from users; Look for a * in the user name column and remove that row in the table. After doing so you may have to flush priveleges;
-
The storage and presentation are two different things in sql. You can display a number any way you want using the format() function. I think that not using a date or datetime column is a very very bad idea... you say you want to, but not the reason why. Nevertheless if you feel you must fight against the features the database gives you, it sounds as if any mysql integer type will work fine for you. In this case the smallest one will work (two digit day/month/year) so a tinyint sounds right.
-
While Dylan\'s way would work, the better way is to use the min() and max() summary functions. Although it\'s unclear, you seem to suggest you have a table with at least these columns: Table TableA ------------------------ id | INT somedate | DATE ... etc What\'s confusing is you state you could have multiple rows which have the same id, only the somedate would be different... or in other words, you have \"groups\" of the same id in TableA. If that is true, then this would get you the earliest date for each id SELECT MIN(somedate) as mindate, MAX(somedate) as maxdate FROM TableA GROUP BY id
-
drop the index and then do a create index.
-
DylanBlitz had some good thinking but he didn\'t really make clear that either you need a seperate provider table (and this would be where the provider would indicate their location (state/zip etc), or you could use Users for that, and have an attribute of that table that would indicate whether the user was a a user or a provider. I would recommend that you might want to retain the services of an experienced developer who understands data modelling and can help you make sure you have the right database structure.
-
Try something like: SELECT *, DATE(ts) as tsdate, TIME(ts) as tstime FROM table
-
I think it matters if someone found your phpmyadmin page, and was able to go into mysql as root because you had no password. From there it\'s quite easy to do a lot of nasty things to not only your database but to the system itself since mysql has the ability to read/write file system files.
-
You managed to pack in quite a few questions here, I\'ll try and answer them: Already you have lost me. The purpose of having a product table is that there should be a row for every product. You indicate that you are creating products that are really \"clients\". This is confusing and my kneejerk reaction is that your design needs work. This requirement would indicate there should be some relationship between the two tables, probably where one has a foreign key, but again exactly what is not clear from your description of the requirements of the application. In RDBMS parlance, what you\'re referring to would be called declarative referential integrity. Mysql does not support this. DRI is good for a few types of things: data driven constraints (table A has TableB.id as a foreign key, database will disallow if you attempt to insert a row where the value of TableB.id does not exist in a row in TableB) or cascading deletes (TableB is a child table of TableA, you delete a row in TableA and all the child rows in TableB would automatically be deleted). It\'s also useful to some tools in being able to reverse engineer the design of an existing database into a database design tool. One product that I\'ve recommended in the past (Dezign for databases) has an importer capability that will create a database design from an existing mysql database, however, it may not be able to actually create the relationships that were intended. While I have used Dezign for databases to design databases and generate the DDL sql to create the tables and indexes, I don\'t have the reverse engineering script so I can\'t really vouch for it\'s capabilities. If your structure is as simple as you describe you might benefit from using somethign like Dezign and simply starting over by creating a design based on what you currently have, and then dropping and recreating it from the Dezign generated scripts. Having designed databases for years, I always use this methodology for my projects, since it guarantees that my database structure is what I think it is, not to mention the benefits of having design diagrams and table and attribute notes to refer to when I am developing. Yes Oracle supports a host of features that you will not find in Mysql, but then again, Oracle costs many thousands of dollars. In my opinion Oracle is the best RDBMS product available, and it\'s list of capabilities is unmatched by any competing product, however lack of DRI is not something that will prevent you from creating a functional reliable application so long as your database design is sound. My phpfreaks tutorial has several diagrams I created with Dezign for databases that illustrate the type of thinking that should go into figuring out what your database design should be. I can see that you have done some thinking about it, and have a grasp of some of the concepts of normalization, but without knowing more about the purpose of the application, I can\'t really help you further unfortunately.
-
It\'s also a good thing to create one or more users and associate them with individual databases for the purposes of developing scripts or using your own script. This command let\'s you create a new user and give that user permissions to use a database called test_db you created with the command CREATE DATABASE test_db: GRANT ALL ON test_db.* TO testusr@localhost IDENTIFIED BY \"testusrpw\";
-
Well you either have a mysql password for the root account or you don\'t. If you don\'t you need to set one, which is what the phpmyadmin message is warning you about. Once you login to mysqladmin you should use the mysql database. Then issue this query to change your root password (in the phpmyadmin sql window): UPDATE user SET Password=PASSWORD(\'somenewpw\') WHERE user=\'root\' Once that query completes, issue this command: FLUSH PRIVILEGES;
-
If this is what you did then it\'s clear what the problem is: This line: C:mysqlbin>mysqldump Should be C:mysqlbinmysqldump You are simply trying to specify the path to the mysqldump command here. So the correct full line should be: C:mysqlbinmysqldump database > C:myfolderexport.sql This calls mysqldump and redirects output to the file c:myfolderexport.sql
-
Why would you need a database of databases? Please describe what you\'re trying to do.
-
I can\'t guarantee this is your problem, but you should not use spaces in the names of your columns. You might try to substitute the name gender instead of \'Male or Female\'. Keep in mind that column names in your table are for your use only... nobody sees these, so keeping them simple and descriptive enough for your use is all that\'s necessary.
-
I don\'t agree with this. A Primary key by definition must be able to uniquely identify any one row in the table. As for NULL, it is often seen as being a property that exists independent of normal SQL rules. When a column is NULL, a value is unknown. Thus even a column guaranteed to be UNIQUE will allow for NULLs if the NULL property is set. For this reason, many SQL purists recommend that NULL be avoided. As for having NULL in a primary key column... that is not allowed. A primary key must have a value and that value is guaranteed unique across the entire series of columns which comprise the primary key.
-
I think your approach is a bit flawed. There is no value in you having the password on the form as an admin. The reason you encrypt the password is to secure it... even from yourself as an admin. The only function you should reserve for yourself as an admin, is the ability to reset the password for the user manually. You should just have a function of your system that lets you supply a new password, and have that stored as the user\'s new password. I don\'t expect that this is something that should be needed very often, if you have adequate self-help functions allowing a user to set a new password for themselves, using some combination of their registered email, or password hints they provide when they set the account up.
-
mysql error 13: unable to read write localhost.pid
gizmola replied to jacsmith510's topic in MySQL Help
It sounds like you the user you are starting mysql with does not have the permissions to create the mysql.pid file. -
select papername, IF(personid is null,\'False\', \'True\') as subscribed from paper left outer join subscription on paper.paperid=subscription.paperid and subscription.personid =1 order by papername The important things: -use left outer join to get a row whether or not Jacque is subscribed -use AND to only get rows from subscription that are Jacque (personid =1). Since a person can only be subscribed to a paper once, this means that we either get a personid of 1, or NULL in the personid column. -use IF on personid to test for NULL (ie a paper that Jacque is not a subscriber to) Don\'t say I never did anything for ya :wink: Now if you get the job, will I be getting a kickback from you?
-
You simply need to join the tables together. In SQL you are always returned a \"set\" ie. a table. Joining two or more tables together creates what you could think of as a temporary table. If I understand you correctly you have two tables that you can join by id_key and parent_id_key. So something like: SELECT * FROM table a, table b WHERE a.id_key = b.parent_id_key AND rank \'unset\'
-
The table may be corrupt. Take a look at running the fixisam or whatever the name of that mysql function is.
-
You need to be a lot more specific, if you expect to get any help. We are not mind readers. Read the posting guidelines document that\'s linked in my sig. It should help you understand the type of information you need to supply. Also this should go in the Mysql forum.