Implementing dropdown menu in phpMyAdmin - sql

I'm learning databases, I have a question:
Is it possible to create a drop down menu in SQL?
for example: Create a drop down menu for Gender, so a user can select either Male or Female?
Many Thanks

If you use MySQL ENUM data types as your table column data type, then phpMyAdmin will present the option values to you as a drop-down selector.
Adding an ENUM column:
Inserting a row:

Related

convert an option value stored in a table field (without a reference table) into a corresponding text

We have a legacy vb6 solution working with an access database with one of the forms containing a number of mutually exclusive option buttons
There is no reference table and the options are saved/loaded using hard coding ie. values in the field optState would be either 0, 1 or 2.
We are building a query in Access to export data into XML and looking for a way to convert the options into text fields without updating the DB or VB application!. So if 0 show some text, 1 some other text ... etc.
Is there a way we can do this in the access query or access sql?
No plans to upgrade the VB or DB so looking for a workaround.
thanks
jay
You could use IIf (Immediate If) to do this in a query. As you have multiple values per field, you would need to nest them. Something like:
SELECT tblStatus.*,
IIf([Status]=0,"Available",IIf([Status]=1,"Sold",IIf([Status]=2,"Withdrawn",""))) AS StatusOut
FROM tblStatus;
This returns an empty string if a value is not 0/1/2. Or you could use Switch in the query:
SELECT tblStatus.*,
Switch([Status]=0,"Available",[Status]=1,"Sold",[Status]=2,"Withdrawn") AS StatusOut
FROM tblStatus;
Regards,

How to find table type for a data element?

I create a new function modul in abap which should return a list of the data element AGVAL.
AFAIK there are two ways now:
I use an already available table type
I create a new table type
How to do this kind of introspection? I would like to now if there is already a table type with one column, which is of type AGVAL?
you can enter your element type in TA SE11 as Data Type.
Go to display and use the Where-Used-List to search for table fields / strucure fields to find the usage of this data element.
Regards
Max
I don't know any option else but using SQL to query the ABAP dictionary directly.
For instance, this query extracts all table types having a structure whose first component has the data element SO_TEXT255 (and which is not embedded in a nested structure) :
SELECT * FROM DD40L
WHERE ROWKIND = 'S'
and ROWTYPE in (
select TABNAME from DD03L
where POSITION = 1
and ROLLNAME = 'SO_TEXT255' )
Of course, it doesn't restrict to structures with only this one component but you may adapt it a little bit.
If you do not stick purely to ABAP-way it is done via SE11 in a very simple way.
Search by table types
Choose search type as "by reference line"
That's it!

Multiplying 2 value in database

I have a database. I created it with HeidiSQL. Its look like this.
I enter the value-1 and value-2.
Is there a way to enter a formula to Result column like " =Value-1 * Value-2 " ? I want my database to calculate the Result when I enter my values to other cells.
A trigger is one way to achieve automated column content.
A second one is a view, which you can create additionally to the table. That view could contain SQL which generates the result:
SELECT value1, value2, value1*value2 AS result
A third (more modern) alternative is adding a virtual column in your existing table. You can do that with HeidiSQL's table editor, like shown in the screenshot. Just add a new column with INT data type, and set its Virtuality to "VIRTUAL", and Expression to "value-1 * value-2". That's it.
I'm not familiar with HeidiSQL, but it appears to be a front end? What RDBMS are you using, for example SQL Server allows a computed column.
SQL
ALTER TABLE YourTable
ADD Result AS ([Value-1] * [Value-2])
Right click your database name in the folder structure, go to --> create new then -->Trigger
Then you can create a trigger that when entering data, will be activated on the entire column like this:
But you will need to know how to write the actual query and function. This requires basic knowledge that is generally generic and consistent of most all SQL languages.

Spotfire 6.0 - Limit Data by Selection from Another Table

I have two data tables A & B in a visualization. They can be joined by a common column ID.
Is it possible that the data chart from table B be limited by selection from table A?
Best Regards,
Jonathan
you can create a relationship based on that ID:
click Edit...Data Table Properties
click the Relations tab
click New to create a new relation
configure the relation by selecting the left and right tables, the column containing the ID on both table, and optionally a method to apply to values in that column
click OK a few times to accept all changes
...and then configure the Filtering panel to show this relationship:
open the Filtering Panel by clicking the button on the toolbar or View...Filters
find the header for your Table B and click the "Filtering" icon next to the expansion arrow (▼)
select Filtering in Table A ► and tick Include
now when you change filters on Table A, data will be limited in Table B to reflect it. only the currently-selected Filtering Scheme will behave like this; any other schemes will also need to be configured (steps 6-8).

WebDriver - locate dynamic column

I am using webdriver to test our application that contain table where the user can change the order of columns in a table,and also can remove/add columns (This is beside new column added by developers).
What is the right way to find the column I need?
One way is to go over the table header to find the column I am looking for so I have the column index and than I can access the right cell.
Is there other way ?
What about put unique id/class name for every element in table ?
Thanks
You can do two things for this situation:
Get handle to table element, and then navigate accordingly to get the columns or rows. Once you have this, then you can do all operations on them like click() etc.
Other way is, see the pattern of their ids/css because, most of the table that I have deal with will be having ids like this:
grid_name_1
grid_name_2
grid_name_3
Then you can have do this way:
String baseLocator = "grid_name_" + clickedRowIndex;
driver.findElement(By.id(baseLocator)).click(); //for click operation
Lets say user wants to click on the 3rd row, then clickedRowIndex will be 3 which selects the 3rd table row.