I assume you’re already properly using the WP Metadata API https://codex.wordpress.org/Metadata_API to attach the field to new comments and you just want to backfill for existing comments by stuffing the database?
If it was my problem, I wouldn’t bother and would assume in my code that absence of meta implied no likes. If you use update_meta_data() to update the values when users like a comment, then it will create the meta key,value pair if it doesn’t exist.
But, to answer your actual question, you don’t want the ASs. This works for me:
INSERT INTO wp_commentmeta( comment_id, meta_key, meta_value ) SELECT comment_ID, 'likes', 0 FROM wp_comments WHERE comment_approved = '1';
Related Posts:
- What SQL Query to do a simple find and replace
- Adding another state (spam, reject, approve) to wordpress comments?
- How to remove Profile Picture section or the message “You can change your profile picture on Gravatar.”
- Add field to posts (checkbox) that only one post can have
- generate unique number when registering a user
- Custom Fields Bulk Edit
- How to get value from custom backend menu
- Allow Users to Set Password During Registration
- How can I manage my multiple wordpress websites from main website?
- Custom protected password page with ACF
- How to find if a post with custom_field == X exists?
- Passing page url into a custom field via the Press-This bookmarklet
- How to extend nav-menu-item-control data in Appearance > Customize?
- Custom column sorting in WordPress admin post table
- show the meta values to visitors that collected via coment form
- Hide custom field if empty
- Query posts by category AND custom field, then ORDERBY another custom field – help!
- list/consult Taxonomy only for the respective author/creator in dashbboard
- Advanced Custom Fields: Sorting custom columns with custom fields sorts only by date
- How to change popular term checklist title when edit post?
- Add a date updated/date modified option using custom fields
- How to add textarea field to taxonomy (tag)?
- How to add an extra button on woocommerce shop page and use it to send the product info with image in a mail? [closed]
- Woocomerce custom billing address fields display in order details [closed]
- The function can not create a table on MariaDB server
- UPDATE on SELECT results. A SQL query to swap Author with Meta Box value
- wpdb custom tables without plugin
- What requirements for ACF custom fields key and name properties?
- My custom sql query for getting a username giving me a warning and an error
- How to insert a writing panel between the title and the page content?
- Toggle custom fields?
- dbDelta not creating tables with composite keys
- Custom SELECT Query With Multiple Meta Values (Ordering Problem)
- Applying WP-cli Search & Replace to Static SQL Dump File
- How to print Array values of custom Fields Meta?
- Get users based on month ACF datepicker field
- What is the best way to modify Admin Panel on WordPress?
- how to make a custom field readonly or disabled by user role?
- theme customizer – can a single option pass multiple values?
- Let author add field to metabox by pressing a button
- How to auto add nofollow to links in custom field?
- Troubles about insering a POST with a SQL query, post_status
- query_posts meta_key with current date
- saving the widgets position after drag and drop
- Is it possible to add custom badges to product attributes conditionally, based on custom field?
- How to get Previous Visited Page Information
- export and import wordpress customization
- WordPress category custom title
- No plugin populate user information in to form
- How can Use custom input field in functions.php page?
- Get All Results From Other Users That Share The Same Custom User Meta As Current User
- Simple custom attributes on posts
- Use a custom page with dynamic content as a user profile page
- WP Query – grouping posts by same meta key, adding together values from another key
- What is my error trying to create a new table in the database?
- Query Product categories what have a custom field
- Adding a drop-down (select tag) option under Menu Settings in WordPress Admin
- Replace publish date in blog module with custom field
- How do I enable the text editer in my WordPress theme? [closed]
- How to add H1 Tag on Homepage?
- Does WordPress support template resources/custom fields
- Change post template the proper way
- Pre_Get_Posts order DESC not registering
- Custom WordPress SQL Query 4 posts per custom taxonomy
- Save And Display Mp3 Audio files on WooCommerce product page with Dokan
- Advice how to connect custom database with WordPress, change data in WordPress and finaly use this data
- Has the table name in SQL for WordPress changed from WP_posts to WPCS_post?
- Add custom information in editor summary
- Customise “Add a New Post” page
- How do I add a promotional message to my posts?
- Changing settings of WooCommerce
- Redirect to another page using contact form 7? [closed]
- WPML Plugin Not displaying multilingual Menus
- What WordPress Hook Is Used Before Signup Data is Saved?
- Code to remove authors with no posts connected to them
- One WordPress install for main site at domain.com and blog at blog.domain.com?
- How do I remove a customiser option from a parent theme in a child theme?
- How to locate where an element is generated?
- Is it possible to change the structure of the HTML generated by the_content()? If yes, how? If not, is there a workaround?
- How to recover permanently deleted blog posts?
- Create “alternative/zebra” boxes in the content area?
- Keep Title and Description always
- Custom CSS at Appearance > Edit CSS is missing after update [closed]
- Theme compression/ minifying or W3 Total Cache – which should I use? [closed]
- How to remove all the items under “Personal Options” on user profile page?
- the_post_thumbnail() returns nothing even though has_post_thumbnail() returns true
- orderby in query_posts
- What is the best way to move a single site from one MS installation to another? [duplicate]
- Multi-site User Sessions
- Extend WordPress Core Classes in OOP Theme?
- How To Load an HTML File As A WordPress Page (With No 301/No Redirect)
- how to display a specific wordpress menu?
- How to get every custom taxonomy names and urls?
- Making a query to the DB using same parameters of loop
- Custom Login Process
- How could I verify whole WP directory before/after working with a freelancer? [closed]
- SQL command to convert all tags in lowercase?
- Installing new theme on running site
- Customize option – add two image uploader under same section
- How to customize