I have a picture gallery (built with Coppermine) and I'm trying to backdate a bunch of pictures; to do so I know that I have to edit two columns (mtime and ctime) in the coppermine DB.
Both columns are contained in a table named 'db_pictures'.
I have already done that manually and I know it works.
Now the problem is that I have to edit approx 300-400 pictures (=300-400 rows, 1 row per picture) in the 'db_pictures' table and it would take forever to do that manually.
I thought this could be done quicky and effortlessy with the right command so I searched the site and found this; unfortunately I get a syntax error when I try to apply this command:
UPDATE db_pictures SET ctime=[new value] WHERE [old value]
What am I doing wrong? Could somebody tell me how to apply the right command, please?
Condition in WHERE clause must evaluate to a boolean value i.e. ´true´ or false, see UPDATE Syntax:
UPDATE db_pictures SET ctime=[new value] WHERE ctime=[old value]
or, as your question seems to be a bit unclear,
UPDATE db_pictures SET ctime=[new value] WHERE mtime=[old value]
Related
I need to do 1 of two things (I believe):
1- Get a Custom Object ID so I can query it directly
2- Get a list of values of a specific field within the Object entries.
Ultimate End goal:
Add and modify rows in my custom object via external API. However to do this I need to check and make sure my new entry/row does not already exist.
What I have:
I have a custom object (called Customer_Arrays__c). It is a table that I can add new rows to (I will call entrys). Each entry has 6 or 7 fields. 1 of these fields is called (external_ID__c). This is the field I utilize to match to new incoming data to see if the entry already exists, or if it needs to add a new row to my table. This Customer_Arrays__c is a child to my opportunity I believe – it is part of every opportunity and each line item I add has a field defaulted to the opportunity.
Help I need:
1- How do I query the value of my Cutomer_Arrays__c based upon an opportunity ID?
2- How do I query a list of values in my (external_ID__c) based upon an opportunity ID?
Thanks for your help! I have read half a dozen+ posts on similar topics and am missing something. Examples of some Past try's that failed:
Select external_ID__c,FROM Custom_Arrays__c WHERE Opportunity='00...'
Select Id (Select ID, Custom_Arrays__c from Custom_Arrays__c) from Opportunity where id ='00...'
List FROM Custom_Arrays__c WHERE Opportunity='00...'
Select Id, external_ID__c, (Select external_ID__c FROM Custom_Arrays__c) WHERE Opportunity__c='00...'
Thanks again!
Only you know how did you name the lookup field (foreign key) from arrays to Opportunity. You'll need to check in setup, next to where external_ID__c is. Since it's a custom field (gets __c at the end), my guess is you went with default.
Try
SELECT Id, Name, External_Id__c
FROM Customer_Arrays__c
WHERE Opportunity__c = '006...'
Thank you eyescream, that got me almost all the way there. Turns out I also needed a __r for the parent child relationship.
Here is a snip out of my final code that works - I think it covers everything:
SELECT Field1__c, Opportunity__r.Id, Opportunity__r.Opportunity__c,
FROM Customer_Arrays__c
WHERE Opportunity__r.Id = '006...'.
Thank you so very much!!!
I'm trying to use the DataImportHandler to keep my index in sync with a SQL database (what I would think is a pretty vanilla thing to do). Since my database will be pretty large, I want to use incremental imports using this method http://wiki.apache.org/solr/DataImportHandlerDeltaQueryViaFullImport so the calls are of the form http://localhost:8983/solr/Items/dataimport?command=full-import&clean=false. This works perfectly well for adding items.
I have a separate DeletedItems table in my database which contains the primary keys of the items that have been deleted from the Items table, along with when they were deleted. As part of the DataImport call, I had hoped to be able to delete the relevant items from my index based on a query along the lines of
SELECT Id FROM DeletedItems WHERE WasDeletedOn > '${dataimporter.last_index_time}'
but I can't figure out how to do this. The link above alludes to it with the cryptic
In this case it means obviously that in case you also want to use deletedPkQuery then when running the delta-import command is still necessary.
but setting deletedPkQuery to the above SQL query doesn't seem to work. I then read that deletedPkQuery only works with delta-imports, so I am forced to make two requests to my solr server as part of the sync process? This doesn't seem right as the operations are parameterized by the dataimporter.last_index_time property, which changes. Both steps would need to be done in one "atomic" action, surely? Any ideas?
You must use the import handler special commands
https://wiki.apache.org/solr/DataImportHandler#Special_Commands
With these commands you can alter the boost or delete a document coming from the recordset of the full import query. Be aware that you must use the $skipDoc field to avoid that the document gets indexed again and that you must repeat the id in the $deleteDocById field.
You can use a union query
select
id,
text,
'false' as [$deleteDocById],
'false' as [$skipDoc]
from [rows to update or add]
Union Select
id,
'' as text,
id as [$deleteDocById],
true as [$skipDoc]
or a case when
select
id,
text,
CASE
when deleted = 1 then id
else 'false'
END as [$deleteDocById],
CASE
when deleted = 1 then 'true'
else 'false'
END as [$skipDoc]
Where updated > ${dih.last_index_time}
The deletedPkQuery is run as part of the regular call to delta-import, so you don't have to run anything twice (and when doing a full-import, there's no need to run deletedPkQuery, since the whole connection is cleared before importing anyway).
The deletedPkQuery should be configured on the same element as your main query. Be sure to match the field names exactly as well, and that the id produced by your deletedPkQuery matches the one provided by the main query.
There's a minimal example on solr.pl for importing and deleting fields using the same deleted_entries-table structure as you have here:
<entity
name="album"
query="SELECT * from albums"
deletedPkQuery="SELECT deleted_id as id FROM deletes WHERE deleted_at > '${dataimporter.last_index_time}'"
>
Also make sure that the format of the deleted_at-field is comparable against the value produced by last_index_time. The default is yyyy-MM-dd HH:mm:ss.
.. and lastly, remember that the last_index_time property isn't available before the second time the task is run, since there's no "previous index time" the first time an index is being populated (but the deletedPkQuery shouldn't run before that anyway).
before asking i wanna to show my tables and their relationships(created with ms access 2007)
here is the schema :
https://plus.google.com/photos/113802558354450440804/albums/5988059068393888337/5988059068667446962?banner=pwa&pid=5988059068667446962&oid=113802558354450440804
in this case, i create 3 combo boxes in VB2010 :
cbx_major(binded to MAJOR table)|major_id as the VALUE MEMBER, major_name as DISPLAY MEMBER
cbx_student(binded to STUDENT table)|student_id as the VALUE MEMBER, student_name as DISPLAY MEMBER
cbx_course( this is the question )
And here is the scenario :
first, i must choose what major is at cbx_major
second, the cbx_student will instruct the STUDENT table to select the student_name where major is equal to the selected value of cbx_major and set that query result as the DISPLAY MEMBER of cbx_student(this is done succesfuly without writing any code )
(this is the question)then the last, i want to set the cbx_course to display the course_name where student_id is equal to cbx_student.
i have done a lot of effort to do this :
i opened the combobox tasks menu and choose the student_course table and trying to create the query but it results "the schema returned by the new query differs from the base query"
i created the query in access by Joinning the table STUDENT_COURSE and COURSE using INNER JOIN then i bind the cbx_course to that query but it results wrong display.
i opened the xsd file then i create the query there but results wrong result
all those effort does not work.
i want to solve this case without writing code but using a technique such setting the taskbar menu, is it possible ? any idea? thanks so much for the attention
I use three fields in Sqlserver Datavbase tables, for prevent delete records permanently by user:
IsDelete (bit)
DeletedDate (DateTime)
DeletedUserID (bigint)
I wish to set third field (DeletedUserID) by UI by some thing like this:
this.ExamdbDataSet.AcceptChanges();
DataRowView row = (DataRowView)this.BindingSource.Current;
row.BeginEdit();
row["DeletedUserID"] = User.User.Current.ID;
row.EndEdit();
this.ExamdbDataSet.AcceptChanges();
row.Delete();
and other two fields ,'IsDeleted' field and 'DeletedDate' are set automatically in table's 'After Delete Trigger'.
then commit changes to database with desire command successfuly with this code:
this.TableAdapterManager.UpdateAll(this.ExamdbDataSet);
but problem is , the 'DeletedUserID' is null in database.
and Question is : How to set 'DeletedUserID' field value by true way in UI?
I don't think it is a good way to do that. You have sliced a simple logic to separate parts, each being done in a different part of the application (UI, Trigger, ...). You set value of some field, and then DELETE the whole record! Don't expect anything else that the current situation.
You would better set all fields in UI (i.e. no trigger in this case), and change the query that loads data. For example,
Select * from table1 where IsDeleted=0
You didn't tell us anything about whether your use ASP.Net or WinForms. Give us more info.
Sorry if the question was asked before i try search but not found. I'm still new on mssql so
maybe the answer are obvious just i cant find.
My current query is:
SELECT gold_min, gold_max, gold_min_2, gold_max_2
FROM m_rdb
I want to divide the values on current columns by 20 and then update, just not sure how to do.
Any help are welcome.
Are you looking for this:
update m_rdb
set col=col/20.0
If your updating the values to same columns then
Update m_rdb SET gold_min = gold_min/20, gold_max=gold_max/20,
gold_min_2=gold_min_2/20, gold_max_2=gold_max_2/20
If your updating the values to Other columns then
Update m_rdb SET gold_min_other = gold_min/20, gold_max_other=gold_max/20,
gold_min_2_other=gold_min_2/20, gold_max_2_other=gold_max_2/20