Best way to store ranges and single values in mysql - mysql

just facing a little problem right now.
I have a layout-table that contains one field pages. This should specify for which pages the layout should be applied.
The possible contents are "closed" ranges like '3-5' or open ranges like '3-*'. But it should also be possible to add single pages.
So is there a good way to accomplish a content like that
'3-5;11;15;17-*'
in a single field?
Or do you know better ways?
Is there a possibility to query this field like
SELECT * WHERE IN_RANGE(pages, '5') (Pseudo-Code)
I want to prevent creating a table page because it would contain nothing else and also don't want to do the validation in php.
I am happy to provide more information if necessary.

This is a tricky question i dont see "native" sql option for this.
My first idea was to store information about pages as varchar and implement method to tokenize that string so youll have values which you can then process by sql query.

Related

When to use lookup field?

Whenever I'm considering the option of making a field's contents being extracted from a predefined list, should I make a new table to list exclusively those options, then make a query, then make a form-level lookup field to select it?
This seems like creating A LOT of tables and queries from those tables, just to have a lookup field. I have no idea what the normal number should be, or if there is a clever way of doing queries without creating new tables everytime that I'm not aware of.
For example: I have an Addresses table, and each address can be of three types: home, professional, other. Should I make a table exclusively to list those items and then reference it through a query and a lookup field in a form?
What's the procedure here? Thanks in advance!
Use table lookup when you are going to use this lookup in another entity or you are going to allow the end-user to edit entries of this lookup. In other cases, be free to confine yourself to use constant list of values.
Feel free to ask more.

SQL query or logic to implement search result

I have a text box and search button same as stackoverflow, I have a field in database "Title", Now i want a sql query or some kind of logic which actually filter the string from "Title" field.
Eg. if I type "Stackoverflow is good website" in a searchbox.
Now I want those records from the table which contains
"Stackoverflow" OR "is" OR "good" OR "website".
I don't know if this is possible using a query or I have to write a logic.
FYI I am using salesforce.
I must have a reputation of 50 to comment so I'll post an answer instead. Using a dynamic query with the like comparison and or operator is the best method for the SOQL method. Depending on the size of your record sets I would look into front end solutions for better filtering methods. If you have several hundred results even, frameworks like angular or even custom solutions (show / hide) can create very nice user experiences with the data.

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.

LINQ to Entity Cross Tab

Is it possible with LINQ to do a cross tab query to add new columns? These columns come from a second and third table and need to be converted to JSON to be displayed in a Telerik table.
One table contains the name of the columns that need to be displayed and the other contains the value for the rows of each column, and this relates to the first table, which has the main related data.
I have investigated dynamically creating the extra columns, but also come unstuck as they need to go through JSON serialization, as well as the difficulties of creating new properties within any class dynamically.
Any ideas would be helpful.
Regards
Mark
I hope this helps, although I'm not sure I understand completely what you're asking ...
Since you're serializing to JSON anyway (and so presumably are not overly concerned with schema/type info), I would suggest just using a Dictionary and populating your data that way. It sounds like you could run some kind of nested loop, cycling through the column names from the one table, and pulling the values from each column from the second table.
EDIT
BTW, it is possible to do dynamic properties using System.ComponentModel, although this seems like overkill from how you described your scenario (you don't require data binding, for instance). Here's a good post on SO, if you're interested: Data binding dynamic data

Access Input textbox on Data Access page with only select enabled to allow filter by searchs

I have a data access page which gets all it's data from a query of another table, problem is all the textboxs I make on the page and bind the Control source to the matching column then don't allow me to input any text in to use the filter option to search all the results.
I don't want to be able to record any information but if I change page properties to from DataEntry = false too true then it no longer displays the whole section of textboxs.
Anybody know of a way round this or suggestions of other simple solutions to display certain data from the table or all the data from the query in the same/similar way as this?
Edit- Original issue which now requires me to find new solution.
I've used DAP quite a bit -- I even built DAP solutions at Microsoft, and they were wildly popular. I always preferred to use the SQL Server flavor of DAP.. and that allows you to use TWO different types of filters, the standard filter property, in addition to the serverFilter property. The serverFilter property is extremely powerful, and it's incredibly nice to be able to filter things in TWO different ways.
Hope that helps
-Aaron MCITP DBA
The original issue has now been resolved but I had also found these 1, 2 links which guide one through a search feature on DAP's.