Perform find over list of values - filemaker

In Filemaker11.
I have a table, with a field categoryID, and want to Perform Find on these records.
I want to display only the records which have categoryID as either 1, 2, 4, 6, 12 or 13.
Perform Find doesn't seem to allow me to set up ORs... or at least I can't see where it does.
How can I do this?
Note: This table is actually connecting (with read-only permissions) to a table from a MySQL database, so I cannot set up a field which displays the boolean isOneOrTwoOr...

While in find mode, go to the 'Record' menu and select new find request. All find requests are ORed together. You can do the same thing in a script by doing the 'new record/request' script step.

you can do something like this (Assuming you using MySql database as you haven't mentioned)
Select * from tablename where categoryID in (1,2,4,6,12,13);
That's simple MySql query

Related

Sails 1.0 Group By

Now that groupBy is deprecated, how can I mimic a SQL command like SELECT COUNT(*) FROM table GROUP BY xxx using the Waterline ORM ?
This page recommends using .sum() and .avg() but these methods are for number-type columns. Here I want to be able to count the rows of grouped columns, whatever type it is.
I think for specific groupBy query, you've got two choices.
The first one is a 2 step action.
1) Select all the unique element "group by field" you've got in the database.
2) Then count the record for each unique group by field element.
The second one is to use .sendNativeQuery() wich allow you to send a native SQL query to the datastore (you can use this only if you use a real SQL server and not the embedded Sails.JS database)
sendNativeQuery() Documentation

How can I query the results of a query in Server Explorer in Visual Studio?

I can get the results of a Stored Proc from Visual Studio by following these steps:
0) Select View > Server Explorer
1) Locate the Data Connection that contains the SP of interest.
2) Right-click the SP and select Execute; if any args are required, it will allow you to populate those in a dialog and then proceed with the execution
Provided that you have provided valid args (and the SP returns data), the results will display in a grid in a T-SQL Results tab.
Now, though, what if you want to query that "dataset" that has been returned, such as to sum the values of a particular column - can that be done right there from within Visual Studio.Server Explorer.T-SQL? If so, how?
UPDATE
I believe Khazratbek, but I can only get this far in a New Query instantiated by right-clicking the Tables folder beneath the Data Connection:
SELECT SUM(QtyShipped), SUM(QtyOrdered) FROM CPSData.
...the options available as a drop down following that final "." do not contain the results of the Stored Proc (SQLQuery1.sql).
Is it really possible?
Server Explorer -. Right click on Tables -> New query. Write your query (you may select from your SP execution results) and just click on triangle sign. Sorry, if I misunderstand your exact question.
Let's think that your stored procedures gives you logins and passwords of users:
select login, password from users;
You are taking one million result, for example. And you don't need to change your stored procedure, but you want to make some job with your results (selecting in some order, changing the order, select by some condition, so on).
Let's continue. Your stored procedure gives you a two column: it is column login and password. So we may consider the results of your SP execution as some table. To work with your result do next steps:
Server Explorer -> Your_database_connection -> Right click on Tables -> New query
Then write the following code there:
Declare #temporary_table_variable table(login varchar, password varchar); --or without datatypes
insert into #temporary_table_variable(login, password) exec MyStoredProc;
SELECT * from #temporary_table_variable where id > 1000; --it is just a simple example
Hope it helps

Can't remap fields - map fields window is missing new table

I have a Crystal Report with a database command:
The command has a join clause that can be removed and read from a table in the database, because it represents static data. I add this table (called _System) to the database expert:
Now I edit the command to remove the join and columns that reference this table. Since the report fields that depended on these columns are no longer mapped, this causes the Map Fields window to appear:
...which does not have the new table in it. If I cancel out of this I am back to where I originally was. If I hit OK without mapping, all of the unmapped fields on the report are deleted (suffice it to say... I was not expecting this >:( )
I have tried adding links between the command and the new table, and refreshing report parameters, but these have had no effect.
One workaround is to manually replace every field in the report, but this is very labour intensive.
Here is the outline of the command before:
SELECT ACT.Account_Code, ACT.Company, ACT.FName, --etc
STM.CompanyName AS 'DLRName', STM.Address_1 AS 'DLRAddress', STM.City AS 'DlrCity' --etc
FROM Accounts AS ACT
JOIN _System AS STM ON 1 = 1
GROUP BY ACT.Account_Code, ACT.Company, ACT.FName, --etc
STM.CompanyName, STM.Address_1, STM.City --etc
And after:
SELECT ACT.Account_Code, ACT.Company, ACT.FName, --etc
FROM Accounts AS ACT
GROUP BY ACT.Account_Code, ACT.Company, ACT.FName --etc
I have removed the JOIN on the _System table, and all referenced columns.
It appears to not be recognizing your _system table as a new source.
I would :
1) leave your command object SQL unchanged & get the issue worked out with the _System table, then
2) ensure that you are able to establish a join between the command object fields and the _System table fields, and lastly
3) then remap the fields.
Step two I suspect is the source of the problem, as your join condition is "ON 1 = 1" which I assume to mean that you may not have a common key field in both tables.
Note that your original command SQL selects STM.Companyname AS 'DLRName'.
Hence, crystal now know of a field called DLRName, but does not know of a field called CompanyName, hence it cannot make the association between DLRName in the old source, and CompanyName in the new source...
Likewise with the rest of the fields that are being moved from the command object to an attached table. if no name match exists...Crystal cant make the connection. However...it would list all unmatched fields that are on the report, and all unused fields in the recognized data sources, and allow you to specify the matches yourself.
But it does not...which tells me that something has gone wrong with the attempt to attach/open the _System table. Hence..you need to get that worked out first, then make the field adjustments.
If this doesnt get you thru...then show some sample data so I can see how the two tables are relating ( ensure some examples exists where there is a row match from both tables ).
I had the same problem a while ago.
Unfortunately I can't find anything online that helps, or maybe wasn't looking hard enough. I just noticed that in my case, that particular field that isn't showing in the map field dialogue box has nvarchar(max) as its datatype (in view).
I tried to force the datatype with CAST(missingfieldname as nvarchar(20)) as missingfieldname (I did this in the view), and voila, it magically appears in the map field dialogue box.
It seems that field mapping dialogue box aren't showing fields with blob texts.
I know this question was asked 4 years ago. But hopefully, this comment could help future solution seekers regarding this absurd and weird problem. I just got lucky seeing what's unique about that particular missing field.

SQL query, select row based on another row

I have a photo review application, SQL Server 2008 R2 back-end. One requirement is to me able to mark photos with anomalies such as "bad lighting," "blurry," etc. Another option is "Unidentified."
Whenever the user chooses "Unidentified," they are required to add an additional anomaly, called "Other," and give it a description. They can have the "Other" anomaly without the "Unidentified," but not vice versa.
I need to create a report that lists all the "Other" anomalies, if the picture also has the "Unidentified" anomaly. No idea how to write a query that accomplishes this. Basically the table has a photoID, and the anomalyID, and a description text field for "other," if required (plus some other irrelevant stuff).
So, the psuedocode would be:
Select PhotoID, Description from photo_anomalies
where photo anomaly "other" description is not null,
but only if there is a matching "unidentified" anomaly for that photoID.
clear as mud?
I figured out a solution - not sure if it's the best but it seems to work. Using a select where = "unidentified" inner joined on the PhotoID with a select where = "Other."

iPhone Dev - Trying to access every row of a sqlite3 table sequentially

this is my first time using SQL at all, so this might sound basic. I'm making an iPhone app that creates and uses a sqlite3 database (I'm using the libsqlite3.dylib database as well as importing "sqlite3.h"). I've been able to correctly created the database and a table in it, but now I need to know the best way to get stuff back from it.
How would I go about retrieving all the information in the table? It's very important that I be able to access each row in the order that it is in the table. What I want to do (if this helps) is get all the info from the various fields in a single row, put all that into one object, and then store the object in an array, and then do the same for the next row, and the next, etc. At the end, I should have an array with the same number of elements as I have rows in my sql table. Thank you.
My SQL is rusty, but I think you can use SELECT * FROM myTable and then iterate through the results. You can also use a LIMIT/OFFSET(1) structure if you do not want to retrieve all elements at one from your table (for example due to memory concerns).
(1) Note that this can perform unexpectedly bad, depending on your use case. Look here for more info...
How would I go about retrieving all the information in the table? It's
very important that I be able to access each row in the order that it
is in the table.
That is not how SQL works. Rows are not kept in the table in a specific order as far as SQL is concerned. The order of rows returned by a query is determined by the ORDER BY clause in the query, e.g. ORDER BY DateCreated, or ORDER BY Price.
But SQLite has a rowid virtual column that can be used for this purpose. It reflects the sequence in which the rows were inserted. Except that it might change with a VACUUM. If you make it an INTEGER PRIMARY KEY it should stay constant.
order by rowid