Skip to content
Advertisement

Tag: database

One table with many field or two table with fewer fields?

My question is simple, currently, I have a database with an “User” table which contains important information about each users (email, username, password), an “Identity” table which contain the first name, last name, birthday… of an user, and a “Medias” table which currently contains fields like “facebook”, “googlePlus”, “twitter”, “youtube”… the address of all medias of the user actually. But,

SQL: Select only one row of table with same value

Im a bit new to sql and for my project I need to do some Database sorting and filtering: Let’s assume my database looks like this: What should I do to only have the last column with the same email te be returned: Thanks in advance! Answer SQL Query: Hope this solves your problem. Thanks.

How to decide which fields must be indexed in a database table

Explanation I have a table which does not have a primary key (or not even a composite key). The table is for storing the time slots (opening hours and food delivery available hours) of the food shops. Let’s call the table “business_hours” and the main fields are as below. shop_id day (0 – 6, means Sunday – Saturday) type (open,

MySQL rows checksum

Is it possible to select entire row in a table and get sort of checksum? I am looking for a way to tell my code to update data only if at least one record has been changed. From perspective of data …

Postgresql delete multiple rows from multiple tables

Consider 2 or more tables: I wish to delete all users and their orders that match first name ‘Sam’. In mysql, I usually do left join. In this example userid is unknown to us. What is the correct format of the query? Answer http://www.postgresql.org/docs/current/static/sql-delete.html You can also create the table with ON delete cascade http://www.postgresql.org/docs/current/static/ddl-constraints.html

RETURNING rows using unnest()?

I’m trying to return a set of rows after doing UPDATE. Something like this. but postgres complains, rightly so: set-valued function called in context that cannot accept a set How am I supposed to go about implementing this? That is, RETURNING a set of rows from SELECTed array after UPDATE? I’m aware that a function can achieve this using RETURNS

where does woocommerce store orders?

I’m looking in the sql db and I can see something that resembles orders inside wp_posts . However, I would expect them to be inside the tables beginning with wp_woocommerce. Can anyone shed some light on this phenomenon? Cheers Answer In woocommerce orders are modelled as a custom post type so they are stored in wp_posts as you found. See

Advertisement