phpMyAdmin not editing correct row - mysql

In my phpMyAdmin, when using the built in interface to edit a field in a row, it will always default to an entirely different query in that row.
AS an example, I edit the row with an id of 5, setting the field "health" from 150 to 160, the query that returns is:
UPDATE `database.characters` SET `description`='' WHERE `id`=5
As you can guess, this is very frustrating, as not only has it not done what I've requested, but it's also cleared the description field. Each row in the database has a different behaviour, some will return no query at all, others will edit different fields and some will have no issue whatsoever.
If I construct the query myself everything is fine, but I have designers who want to edit using the interface.
Any help on this matter would be greatly appreciated.

Related

Updating one table in MS Access with data from another

In MS Access 2016 I have a table named Master that periodically needs to gets updated with ‘updated’ data from a table named NewData. Each table has the same fields, except Master has one additional field named OTHER_SOURCES (explained further down). They each have an indexed unique id field named EVENT_ID. I’ve built an update query where the tables are joined one-to-one on the EVENT_ID field. In this query I have the fields in Master getting updated to the new values from the same fields in NewData if the TIMESTAMP field value is different. If the TIMESTAMP values haven’t changed, then those records do not get updated. This part is pretty straightforward and works fine.
However, I have end users that may make occasional changes to the values in the SIZE field of Master that need to be preserved and not overwritten with updated values from NEW_DATA. When a user makes a change in SIZE field, he documents the change with information obtained from other sources, which is stored in the extra field I mentioned earlier: OTHER_SOURCES. Here’s what I need to do, and I just can’t figure it out. Whenever a user has made a change to the SIZE field for a record, I need the update query to not override that value in the SIZE field, but still update the values in all the other fields (again, assuming the TIMESTAMP values are different between the two tables). It seems I need to use an IIF statement, but I’m thinking it needs to be done in VBA where I’m a bit of a hack. See screenshots. I greatly appreciate any help you can offer.
enter image description here
enter image description here
You can still proceed with the update, but update it to the same value as its previous value:
SET SIZE= IIF(nz(OTHER_SOURCES,'')<>'', MASTER.Size, NEW_DATA.Size)
This assumes that anything present in the MASTER.OTHER_SOURCES column indicates that the user has changed MASTER.Size. Note that MASTER.Size will never be updated from NEW_DATA.Size until someone (end user) removes MASTER.OTHER_SOURCES.

Why does SQL workbench always return a row full of null values in every query?

Every query has a final row with an asterisk beside it and null values for every field? Why does this show up? I cant seem to find an explanation for it. Even putting a WHERE clause doesnt seem to get rid of it. Is this only happening to the MySQL implementation alone?
It is for inserting a new row, you enter the values there.
Are you sure it's not just the data entry row. Usually when viewing the table data in something like Workbench or SQLYog, it will display the rows of data, plus a blank row at the end that is used for adding new data. It will show NULL for each column if that is the default value for that columns data type
Yea, you can type the values directly when you click on the box instead of writing “insert into…” in your query tab

How to Make ActiveRecord always update a field?

When using ActiveRecord, if you are updating a record, it only adds the fields that have changed to the query. I need a way to tell it to always add a particular field to my query, even if Rails doesn't think it changed. In my example, I always want to set a field to "U" when saving a record. The name of the field is DELETE_FLAG. So, I want to see DELETE_FLAG="U" in the UPDATE query that is sent to MySQL every time.
I've tried DELETE_FLAG_will_change! In the model, but that doesn't seem to have done anything, perhaps because I put it in the wrong place?
I've seen the touch method as well, but this will not do. I don't want to update the record again afterwards.
This seems so basic, I'm sure I must be overlooking something here. Any help would be appreciated. Thanks!

How to add a calculated column using conditions in a query in MS Access 2010

I have two tables and from that I am generating a query. I have columns in my query with field type yes/no. These are basically columns to determine the race of a person. The user enters information in yes/no for various races. I want another calculated column in the query which checks for all other race columns and calculates values in it.
I have to check for a few conditions in for the values in columns
For example:
1) If Hispanic is chosen, the new column should say hispanic(no matter what other options are selected. This is like a trump card)
2) If more than one is selected, then new column entry should say "multi"
3) If none of the options are selected, it should say "unknown"
4) If exactly one of them is selected, then that race should be displayed
Can anyone help me with this? I am new to Access
I can't code it for you but I can point you in the right direction. What you want to do is take all the tests you explained above and put them in a coded format :
iif ( condition, value_if_true, value_if_false )
Since you have a lot of possible outputs i'd use something like a Case Statement where you can test for all the possibilities.
Follow this link if you need any info on how to code both type of statements (iif and case).
Once you have tried something like this, you can comeback with a specific question if you encountered a problem in the process.
Good luck with your database.

Access filter won't show value list to choose from after 1st filter is set

I'm having a little trouble with the form filter in Access 2007. I'm using the listview in a few forms and the user needs to be able to filter there.
For testing purposes I made a query, which is just based on one table. If I want to set the first filter, it looks like that:
I choose a value and if I want to set another filter (on a different field obviously), there aren't values available to choose from.
This seems to happen only if I use a query (doesn't matter if I use every field, or just a few, based on one table or multiple linked tables). I can of course use the number filter and enter a value manually.
I have another database, where I can use filters when and wherever I want, regardless whether it is a query or a table - I have a list with values to choose from everytime. This means I messed something somewhere up but I have absolutely no clue where.
I'm using Access 2007 (FE/BE), if you need any further details, just ask. Any advice where to start looking is very appreciated!
Well, after playing around for a long while, I figured out what the problem is.
The form recordsource needs to be a query - no sql code, no "select * from query", just the name of a query. Anything else leads to the fact that you are limited in using the filters. I'm not sure if this is a bug or if there is a reason behind this, but that's the way it works in access 2007 - at least for me.
Before I was dynamically adding conditions to my queries which led to a recordsource like "select * from qDeliveries where location = 1". To accomplish this I now just create a temporary query which is the form recordsource instead of just using the sql code.
Hope this helps anyone... :)
Instead of using a query, try this:
File >> Options
Current Database
Scroll down to Filter lookup options
Check ODBC Fields
Close and re-open the file. That should solve the issue.
Create a Separate query and assign to that form. instead of create query within the form. Your problem might get resolved. I did the same way it's working fine for me.